So I have a page that display posts from a certain category. If that is the category, its outputs one way, otherwise, it outputs another. The problem is, the pagination is only working on the 'other' catgeories. The code for the pagination, and all the data is exactly the same. The only things thats changing is the display.

On the Category it doesn't work on, the pagination links appear, the url goes to the appropriate page/2, but the posts don't update to the second page of posts.

Seems odd thats is the same code, and yet, one Category display fine and another doesn't

Here's the gist of the code:

<!-- Grab the Category from Custom Field -->
<?php $category = get_post_meta($post->ID, 'Category', true); ?>
<?php $cat = get_cat_ID($category); ?>

<!-- Set up Paging -->
<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; ?>

<!-- Query Arguments -->
<?php $args = array(
        'cat' => $cat,
        'paged' => $paged

<!-- Query Posts -->
<?php query_posts($args); ?>

<!-- Begin Loop -->
<?php if (have_posts()) : ?>

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

        <?php if ($cat == 1): ?>

                      <!-- Print certain format -->

        <?php else: ?>

                      <!-- Print in a different format -->
        <?php endif; ?>

    <?php endwhile; ?>

    <!-- Posts Nav Links -->
    <?php posts_nav_link(' | ', '« Newer Entries', 'Older Entries »'); ?>

<?php endif; ?>

Change your query_posts call to include global $query_string variable.

Your query_posts should look like following:

global $query_string;
query_posts( $query_string . 'cat='.$cat ); 
  • hm, that didn't seem to do it. it actually just messed up the data a bit – dtj Sep 19 '11 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.