0

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?

<?php
$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'])) {
 $args['tax_query']=array(
                     array(  
                      'taxonomy' => 'portcat',
                      'field' => 'slug',
                      'terms' => $_GET['slug'] 
                    ) 
                );
        }
1
  • This question might help you. You should use 'operator' => 'NOT IN' in your taxonomy query.
    – RRikesh
    Commented May 7, 2013 at 5:24

1 Answer 1

-1

Please take a look at this example;

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'movie_genre',
            'field' => 'slug',
            'terms' => array( 'action', 'comedy' )
        ),
        array(
            '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;

http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.