Support » Fixing WordPress » Paging Issue on Category Template

  • Resolved alexleonard


    Hi there,

    I have been digging around the various information on paging in the word press codex and forums and am having trouble finding an answer. It’s possible that I am not understanding the issue correctly.

    I have a category which I display on my site as a single page. It is using a dedicated template page “category-8.php” to display posts in a different way. You can view it here:

    To display just the items from my portfolio I am using the following code:

    <?php query_posts('category_name=Portfolio&showposts=8'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post-wrap" id="post-<?php the_ID(); ?>">
    <h3 class="post-title clear"><?php the_title(); ?></h3>
    <p class="index-meta"><?php the_time('F Y'); ?></p>
    <div class="story-content">
    <?php the_content('Continue Reading &raquo;'); ?>
    <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    </div><!-- end post content -->
    </div><!-- end post -->
    <?php endwhile; ?>
    <div class="nav">
    <div class="previous"><?php next_posts_link('&laquo; Previous') ?></div>
    <div class="next"><?php previous_posts_link('Next &raquo;') ?></div>
    <?php else : ?>
    <h2 class="post-title"><?php _e('Not Found'); ?></h2>
    <p><?php _e("Sorry, but you are looking for something that isn't here. Double check your URL or you should try searching for it."); ?></p>
    <?php @include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

    The problem lies with attempting to view page 2 of the portfolio. When you go to the 2nd page it just displays the first 8 posts all over again.

    Other paging in effect on the site seems to work fine, I assume it is a problem with my category-8.php file but am unsure what. Any advice would be greatly appreciated.

    Kind regards,


Viewing 3 replies - 1 through 3 (of 3 total)
  • I have needed to update my code as I am sending the portfolio page a link to a potential client.

    I have changed it to display 10 of the 11 portfolio items we have so that the issue is still noticeable. It is definitely something we’d like to have sorted out soon though as it looks like strange behaviour to a potential client!

    Ok. After playing around with another word press install I’ve worked out what was causing the problem, in case anyone else is having this issue.

    The following line was causing everything to go wrong!

    <?php query_posts('category_name=Portfolio&showposts=8'); ?>

    I assume this meant that whenever category-8.php was loaded it was querying posts before running the loop and choosing the most recent 8 posts. This affected paging as a result.

    I would still like to know how to show less posts than my standard blog page on a specific category page, is this something that I can control with the loop?

    Try this:

    <?php query_posts($query_string.‘category_name=Portfolio&showposts=8’); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Paging Issue on Category Template’ is closed to new replies.