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?

2 Answers 2


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


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

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.