WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

When going to http://craigmdennis.com/articles/ Wordpress uses the index.php template.

When you go to http://craigmdennis.com/2010/05/ Wordpress uses the same template (markup below) but shows the same posts.

I have tried:

  • Disabling all plugins - no change
  • Changing the permalinks back to default
  • Using an archive.php file.

It's obviously something to do with my loop.

<?php get_header(); ?>

        <!-- index.php -->

        <div id="content" class="content clearfix">

            <div class="grid_8">

                <?php if ( have_posts() ) : ?>

                    <?php query_posts('posts_per_page=10&paged='.$paged); ?>

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

                            <article id="<?php the_ID(); ?>" class="post">

                                <h3 class="post-title">

                                    <a href="<?php the_permalink(); ?>" rel=bookmark"><?php the_title(); ?></a>


                                <?php the_excerpt(); ?>


                    <?php endwhile; ?>

                <?php endif; ?>

                <?php wp_reset_query(); ?>

                <nav class="pagination"><?php posts_nav_link(); ?></nav>


            <?php get_sidebar(); ?>


<?php get_footer(); ?>

Can anyone shed some light on what I'm doing wrong?

share|improve this question
up vote 0 down vote accepted

That's because you overrule the query. You have to put the original info into the query_posts like so:

<?php global $query_string; query_posts($query_string . 'posts_per_page=10&paged='.$paged); ?>

For more info look here: http://codex.wordpress.org/Function_Reference/query_posts#Usage_Note

share|improve this answer
This worked perfectly. Thanks – Craig Dec 21 '11 at 11:36

You've overwritten the query. I would set it up this way:

  1. remove the query_posts and reset_query parts and have a standard loop
  2. save the file as archive.php

if should paginate on it's own, and the number of posts will be based on what you set in the reading settings. If you need a separate amount of posts for the archive page, you can set a pre_get_posts filter as such:

function my_archive_display( $query ) {
    if ( !is_admin() && 
        is_date() )
        $query->set( 'posts_per_page', '10' );
    return $query;

add_filter( 'pre_get_posts', 'my_archive_display' );

I assumed this was a date-based archive. You can set whatever conditional is relevant. List of WordPress conditional 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.