Check if WordPress post has a specific category

A WordPress website has this structure:

TopCat1 > subcat > post

TopCat2 > subcat > post

TopCat3 > subcat > post

What is the PHP code to show the word checked only if current post has a specific top level category named “TopCat2”?
It doesn’t mind if it’s inside a subcategory or not.

Read more here: Check if WordPress post has a specific category

Leave a Reply

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