QUESTION: Is it necessary to include the wordpress loop in page.php? If it is not necessary, why do many themes (including the wordpress 2013 default theme) include it?

I noticed this discussion on the wordpress forums, but I didn’t understand the final answer.

furthermore it is stated,

You use The Loop in your template files to show posts to visitors. (Source:http://codex.wordpress.org/The_Loop_in_Action)

BACKGROUND: I am attempting to develop special page templates, and I realized that I don’t quite understand what the benefit is of including the loop for pages.php, because after all, pages don’t care about posts, that is something that concerns index.php.

2 Answers
2

Including Loop is not necessary, but recommended. Also, if you want to use some features you need the loop, for example:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>

Leave a Reply

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