Archive – same title for the first two posts

I created an archive page called archive.php

Here I include header / footer and this code:

Read More
<?php if (have_posts()) : while (have_posts()) : ?>
              <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><a/></h1>
              <?php the_post(); the_content();  ?>
              <br />
<?php endwhile; endif; ?>

The problem is that when there are more posts for a month, the first two posts have the title and permalink of the first post. How can I fix this?

Anticipated thanks!

EDIT

Good advice toscho.

I fixed it, here’s the solution:

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

<h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><a/></h1>
<?php the_content(); ?><br />

<?php endwhile; ?>

Related posts

Leave a Reply

1 comment

  1. You have to call the_post(); before you use the_permalink() or the_title(). Both functions work with a global $post object that will be set up by the_post();.