Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
WordPress Loop Overview1:23 with Zac Gordon
The WordPress loop is the basic logic used to display post and page content. Before we move into coding the loop, we will take a look at it from a conceptual level.
For project files please refer to the first video: WordPress Variables, Tags and Functions
The WordPress Loop is the basic logic
used to display post and page content.
The loop starts with an 'if' statement
that checks to see if posts or pages are available.
The loop is smart enough to know
whether you're on a page listing posts,
on a single post page, or a normal page page.
What's great about this
is that we don't have to change our basic loop
when working with posts or pages.
Next comes a 'while' loop.
On a normal page, this while loop will only execute once.
However, if this is a blog listing page,
it will execute as many times as there are number of blog posts to display.
Inside of the loop, we can then output items
from the post object, like the title and the content of the page.
Add some basic HTML and we now have a basic WordPress loop
that would display the title and content of a post or page,
or a list of posts.
This WordPress loop is highly customizable.
However, this basic loop is what we'll use to display
almost all of the content for pages, posts, and custom posts in WordPress.
In the next video, we'll take a closer look at the code used to create the loop.
You need to sign up for Treehouse in order to download course files.Sign up