December 2017
Beginner
458 pages
7h 52m
English
If there are posts then we want to loop through them. We can use a while loop to do that. So, inside the if statement, we'll add <?php while(have_posts()) : the_post(); ?>. Then end the while loop by adding <?php endwhile; ?> as shown here:
<?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?> <?php endwhile; ?><?php endif; ?>
While it has post, we want to spit out the content file, whether it's content.php or content-gallery.php that pertains to whatever format we choose in the post. So, we'll add <?php get_template_part(); ?> inside the while loop. Next, pass in content and for the second parameter, pass get_post_format(). This will determine whether the post is a gallery or just a standard ...
Read now
Unlock full access