WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

I have a custom post type called 'portcat' and I want to exclude one portcat category ('weather' - ID='5') from the page. I've tried 'category__not_in' => array( 5 ) but apparently this doesn't work with custom post types. What can I add to the below code to exclude it?

$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
             $args = array(
             'post_type' => 'port',
             'paged' => $paged,
             'posts_per_page' => get_theme_option("portfolio_work_count"),           

if (isset($_GET['slug'])) {
                      'taxonomy' => 'portcat',
                      'field' => 'slug',
                      'terms' => $_GET['slug'] 
share|improve this question
This question might help you. You should use 'operator' => 'NOT IN' in your taxonomy query. – RRikesh May 7 '13 at 5:24

Please take a look at this example;

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
            'taxonomy' => 'movie_genre',
            'field' => 'slug',
            'terms' => array( 'action', 'comedy' )
            'taxonomy' => 'actor',
            'field' => 'id',
            'terms' => array( 103, 115, 206 ),
            'operator' => 'NOT IN' //you must set the operator to NOT IN
$query = new WP_Query( $args );

See WP_Query in the Codex for more details;


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.