Is including the loop necessary for page.php?

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.

Read More

furthermore it is stated,

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.

Related posts

2 comments

  1. 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; ?>
    
  2. I think you’re also confused by terminology, as the wording in WordPress is a bit, well, confusing.

    So all post types, including pages are special types of posts. So “post” can mean the actual usable post type “Post” as well as the general term of all content like “Page” or any other custom post type.

    When the Codex says

    You use The Loop in your template files to show posts to visitors.

    What it actually means is

    You use The Loop in your template files to show posts, pages or any other single item of a custom post type to visitors.

Comments are closed.