Answer the question
In order to leave comments, you need to log in
How to get the id of the highest parent term in the page of the current term?
Custom taxonomy term list:
Category 1
-subcategory
--subsubcategory (located here)
code is:
$term_id = get_queried_object_id();
$child_term = get_term( $term_id, 'my_taxonomy' );
$term_parent_id = $child_term->parent;
Answer the question
In order to leave comments, you need to log in
issue resolved :)
$term_id = get_queried_object_id();
$ancestor_cat_ids = get_ancestors( $term_id, 'my_taxonomy');
$term_parent_id = $ancestor_cat_ids[count($ancestor_cat_ids) - 1];
echo 'вот та самая id самого верхнего уровня родителя' . $term_parent_id . '';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question