Menu
I have ID of term child, I need find out this child-parent by child ID, it’s possible, maybe someone can help with this?
I used this but its not working
$terms = get_the_terms( $_product->id , ‘product_cat’);
if($terms) {
foreach( $terms as $term ) {
$term = get_term_by(“id”, $term->parent, “product_cat”);
if ($term->parent > 0) {
$term = get_term_by(“id”, $term->parent, “product_cat”);
}
$cat_obj = get_the_terms($term->term_id, ‘product_cat’);
$cat_name = $cat_obj->name;
}
}
echo ‘<br />(‘. $cat_name . ‘)’;