Using has_term() function for category-subcategory structure

Question

I need to check more than one sub-category for has-term() function.
For example;
Assume that I have 2 categories; Bars and Musicians.
Also, the Musicians category has got Jazz, Rock, Pop as a subcategory. But, they are also subcategories for Bars.

I want to write different codes for Bars – Jazz, Musicians – Jazz categories.

This code structure is not working for me.

if( has_term( 'jazz', 'genre' ) ) {
    // do something
}

Because I have jazz subcategory under Bars and Musicians.

When I wrote a code with this structure, it was not working too.

if( has_term( array('musicians','jazz'), 'genre' ) ) {
    // do something
}

How can I solve this issue?

0
083N 3 months 0 Answers 21 views 0

Leave an answer