Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress get current post term parent by child ID

In page I have ID of term child, I need find out this child parent by child ID, it's passible, maybe someone can help with this ?

like image 718
Mantas Kudeikis Avatar asked Jan 29 '13 20:01

Mantas Kudeikis


1 Answers

That's what the get_term function is for:

$term_id = 21; // Lucky number :)

$child_term = get_term( $term_id, 'category' );
$parent_term = get_term( $child_term->parent, 'category' );

Replace 'category' with whatever taxonomy you're using.

like image 112
Joseph Silber Avatar answered Sep 21 '22 12:09

Joseph Silber