Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
If they are the same how can I display the main posts loop under the loop of the page? –  janoChen Jan 25 '11 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 '11 at 9:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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