Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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; ?>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Change your query_posts call to include global $query_string variable.

Your query_posts should look like following:

<?php 
global $query_string;
query_posts( $query_string . 'cat='.$cat ); 
?>
share|improve this answer
    
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

 
discard

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.