0

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?

2 Answers 2

2

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.

2
  • That does not actually work. The posts with category 4 or 7 are still showing up.
    – GavinR
    Jul 26, 2011 at 18:27
  • answer edited; rewritten with different query parameter.
    – Michael
    Jul 27, 2011 at 20:10
0

Use this instead:

global $query_string;
query_posts( $query_string.'&cat=-4,-7' );

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.