What's the code of the loop which retrieves the Page title and description?

I checked the code inside page.php of the Starkers theme (I guess is the same as the TwentyTen theme):

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

     <?php if ( is_front_page() ) { ?>
      <h2><?php the_title(); ?></h2>
     <?php } else { ?> 
      <h1><?php the_title(); ?></h1>
     <?php } ?>    

      <?php the_content(); ?>
      <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
      <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>

    <?php comments_template( '', true ); ?>

I looks identical to the loop which retrieves the main (blog) posts.

What's the difference?

Which is the part which retrieves the title and content of the current Page?

1 Answer 1


As usual - the_title() and the_content(). Posts page and a PAGE page are different in amount and type of content, but mechanics of main Loop and template tags are essentially same.

  • If they are the same how can I display the main posts loop under the loop of the page?
    – wyc
    Jan 25, 2011 at 9:08
  • @janoChen strictly speaking you can't. You can create secondary Loop (get_posts() or separate WP_Query object) that will mimic that. There is no difference in result, but there is difference in logic and mechanics. Basically main Loop controls what post/page/archive/whatever is. Secondary Loops can be whatever you want (as long as they don't mess with and break main Loop).
    – Rarst
    Jan 25, 2011 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.