How do you get the ID of the parent term of the current child term assigned to a post. For a custom taxonomy?
Custom taxonomy: "location"
- New York
Say we are on a post assigned to "Japan" how do I get the ID of the parent called "Countries"? For this case it doesn't matter if it takes the highest parent or just the direct parent.
I found this:
$term_id = 21; $child_term = get_term( $term_id, 'location' ); $parent_term = get_term( $child_term->parent, 'location' );
But it doesn't work.