Select all posts which do NOT have a certain tag

In WordPress, how can I select all posts in a certain category (custom taxonomy), which do NOT have a certain tag (custom taxonomy).

The following code select all posts in a certain category (custom taxonomy), which DO have a certain tag (custom taxonomy). How does this have to be modified?

Read More
$postquery = new WP_Query( array( 
    'post_type' => 'myposttype', 
    'mycategory' => $cat, 
    'posts_per_page' => $numposts, 
    'orderby' => 'date', 
    'tax_query' => array( array(
        'taxonomy' => 'mytag',
        'field' => 'slug',
        'terms' => array('select by this tag', 'and this tag', 'and this tag'),
        ) )
    )
);

(I assume it would be better to just list all allowed tags, but that’s not really feasible in my case, because new tags are still added.)

Related posts

Leave a Reply

1 comment