Check if a post is in any child category of a parent category

Question

In a site I’m developing, I have the following category structure:

* movies (parent)
    * thriller (child)
    * comedy (child)
    * drama (child)

The current post is in the comedy category. The has_term function with the following parameters returns true:

has_term( 'comedy', 'category' )

But, the same function with the following parameters returns false:

has_term( 'movies', 'category' )

My question is, is there a core function to check if the current post is in any child category of a specific parent category? If not, how can I check this?

Thanks in advance

0
leemon 4 months 0 Answers 10 views 0

Leave an answer