WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this loop in my index.php:

      <?php if (have_posts()) :
          while (have_posts()) :
            get_template_part( 'post' );
        endif; ?>

which calls this template

 <h2 id="post-<?php the_ID(); ?>">
 <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
 <?php the_title(); ?></a></h2>
 <?php the_post();
 the_content(); ?>
 <p class="date"><?php the_time('l, j F Y'); ?> </p>
 <?php trackback_rdf();

The loop behaves strangely printing out titles and posts in this order:

  • Title post #1
  • Content post #1 (and this is ok, but then...)

  • Title post #1

  • Content post #2

  • Title post #2

  • Title post #3 (and so on...)

What am I doing wrong?

share|improve this question
up vote 1 down vote accepted

the_post() function is what advances the internal counter and loads the data for the next post. You're calling it between the title and content:


You want to change the order and move it before the output of any of the other template tags:

share|improve this answer

Your Answer


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.