WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


Hey everyone I have the wp loop to display posts, but I need to exclude category 81. I tried: query_posts('cat=-81'); ?> before the loop but the pagenavi is broken and it doesn't work properly.


    <?php  if(have_posts()): ?>

                <ol class="list posts">

                    $end = array(3,6,9,12,15,18,21,24,27,30,33,36,39,42,45);
                    $i = 0;
                    while (have_posts()) : the_post();
                    global $post;


I have this in the begining of the page - maybe it has something to do with it?:

<?php get_header();

global $wp_query;
$curauth = $wp_query->get_queried_object();
share|improve this question
up vote 1 down vote accepted


global $query_string;
query_posts( $query_string . '&cat=-81' );


share|improve this answer
Awesome, that worked perfectly. Will it be problem to leave the global $wp_query; $curauth = $wp_query->get_queried_object(); along with the new global You posted? Will there be any problems in wp? – jimilesku Mar 27 '12 at 12:04
I would not expect any problems with that. – Michael Mar 27 '12 at 13:38
Cheers, it works fine! – jimilesku Mar 27 '12 at 14:18

Something like this would work

$cat = ( !empty( $wp_query->get('cat') ) )
    ? wp_query('cat').',-81'
    : '-81';

But what you really want to be doing is using tax_query and just setting the taxonomy parameter to category.

share|improve this answer

Your Answer


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.