The WordPress Loop

The WordPress loop is the built-in tool used to allow you to get posts from your WordPress database and display them to your website / screen through a WordPress theme template file. The WordPress loop is a powerful tool that controls the display of the posts, you can display a list of posts by a specific author, date, title and category. The loop is PHP code that is placed within your chosen themes index.php page and can be easily edited and updated to display the details of your posts.

The code will not update if there is an error within your code, I found that from assessment 2 that  the WordPress theme I chose only wanted 1 set of opening and closing php tags and all code had to sit between the opening and closing tags <?php  ?>

 The have_posts  () checks to see if there are any posts and post them to your site.  while ( have_posts () )  : the_post(); this will display all the posts that have been written. By adding in some conditions into the loop we can start to filter out things like date and author by adding the_author into the php code will display the author of each post.

 

Recommended Posts

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *