0

I'm writing a theme in which I've registered "Services" as Custom Post Type that supports "Type of Service" Custom Taxonomy.

I want to list all the posts of type "Services" except those which have "Featured" as "Type of Service" term set. I can write code to list the Posts that are under specific Taxonomy term; but how to write wp_query that will exclude posts from certain Custom Taxonomy term?

Waiting for your reply...

Cheers,

\r

1 Answer 1

1

Sounds like you're looking for the NOT IN value of the operator argument of a tax_query.

Depending on your situation, you should use either WP_Query or pre_get_posts.

Your tax_query would then look something like this:

'tax_query' => array(
    array(
        'taxonomy' => '{your taxonomy slug}',
        'field' => 'slug',
        'terms' => 'featured',
        'operator' => 'NOT IN'
    )
)
1
  • Thanks so much for the answer. This worked for me; I didn't know the "operator" parameter.
    – Ruturaj
    Commented Feb 11, 2015 at 6:22

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.