My wordpress site has categories with a simple hierarchy –

  • Blog
    • Role Shift
    • Urod the Last Show
    • News

I’m using the if statement below to catch if the post is in category blog or any of the child categories – and it works – but it feels stupid not to be able to just check the parent of the current category (plus I might want to add categories later).

if ( is_category('blog') || in_category(array('role-shift', 'urod-the-last-show', 'news')) )

I’ve searched and tried every suggestion – including cat_is_ancestor_of – but nothing is working.

Please help!

Robert

Read more here: Check if category of post is x or is child of x


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: