1

Is there a way to query posts which do not have tags assigned to them?

query_posts('tag='tag_exmaple'&posts_per_page=-1');      

Ty very much!

2 Answers 2

3

Either use the tag_not_in parameter if you have the tag id and if not then you can use tax_query parameter like so:

$tag_to_exclude = 'example_tag';
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
        array(
            'taxonomy' => 'post_tag',
            'field' => 'slug',
            'terms' => array($tag_to_exclude),
            'operator' => 'NOT IN',
        )
);
query_posts($args);
0

You could get an array of all of the tag ids and send it to the "tag__not_in" parameter. Not the most elegant solution, but I'm not sure how else it would be accomplished.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.