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.

I have added query_posts() to my index.php file to modify the loop on the posts page:

query_posts( 'cat=-4,-7' );
get_template_part( 'loop', 'index' );

This works correctly, but when I click on "Older Posts" (link to /page/2), the latest posts show up instead of the previous ones. How can I get my pagination to show the correct posts?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

different approach:

global $wp_query;
$args = array_merge( $wp_query->query, array( 'category__not_in' => array(4,7) ) );
query_posts( $args );
get_template_part( 'loop', 'index' ); 

if this approach should not work, please check if one or more of the plugins is interfering - deactivate all plugins; if the exclusion of categories works then, re-activate one plugin at a time to find the interfering plugin.

share|improve this answer
    
That does not actually work. The posts with category 4 or 7 are still showing up. –  GavinR Jul 26 '11 at 18:27
    
answer edited; rewritten with different query parameter. –  Michael Jul 27 '11 at 20:10

Use this instead:

global $query_string;
query_posts( $query_string.'&cat=-4,-7' );
share|improve this answer

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.