Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Simple Loops0:44 with Zac Gordon
Now that we have covered conditional statements, we will briefly introduce the While loop and show how it fits in with a conditional statement.
The most simple loop we find in WordPress is the WHILE loop.
This loop says repeat the same bit of code as long as a given condition is true.
So, if we took our example from the last video,
we would modify it with the WHILE loop like this.
The first example will only work for one post.
But the second example will work for
as many posts as we have set to display for a given page.
All of this is still very theoretical and may not make complete sense yet.
So let's take a look now at some actual code in a WordPress theme
to see this conditional statement and
WHILE loop combine together in what we call in WordPress, the loop.
You need to sign up for Treehouse in order to download course files.Sign up