In yesterday’s post, I shared how to determine if a given term has a child term. The idea behind doing this is to check to see if a given WordPress term has a child and if the child is actively applied to the post (or post type) in question.
But there’s a caveat that I didn’t mention:
Just because a term has a child doesn’t mean the term itself is actually active.
This means that you could technically be getting a false positive if you’re using the previous method as your sole means to determine if a term has a child. Instead, you need to do one more thing: Check to see if the post has the term applied to it.