• Is there a way to use in_category to display something if it’s *only* in that category?

    For example, I want something to display if it’s only in Cat1. If I have a post that has both Cat1 and Cat2 attached to it, then it won’t be displayed.

Viewing 1 replies (of 1 total)
  • Hi There,

    You’ll most likely need to do this with WP_Query and have a look at the tax_query parameters available.

    https://codex.www.ads-software.com/Class_Reference/WP_Query#Taxonomy_Parameters

    you’d want to get an array of all catagory id’s and remove the id of the catagory you want from that array. Then create a taxonomy query, with an ‘AND’ relationship between two tax queries, one with a ‘in’ operator and the other with a ‘not_in’ operator.

    Let me know if you stumble with this or need a little more help.

    Kind Regards

    Paul

Viewing 1 replies (of 1 total)
  • The topic ‘If *only* in category’ is closed to new replies.