WordPress: How to display and exclude a category or tag using tag__not_in

If you’re coding a custom select posts from database based on arguments and want to exlude a tag or category, then just use tag__not_in to exclude. Done.

$args=array(
	'cat'=> '2',
	'tag__not_in' => array('45')
);

So a working example is something like this:

<?php query_posts(array('tag__in' => array(374),
'tag__not_in' => array('456'))); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *