$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
echo $term->name;
echo $term->description;
echo $term->parent;
Name gives the name.
Description gives the description.
Parent gives the parent ID, not the term.
How do I get the parent term (the word)?
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
echo $term->name;
echo $term->description;
echo $term->parent;
Name gives the name.
Description gives the description.
Parent gives the parent ID, not the term.
How do I get the parent term (the word)?
Share Improve this question edited Aug 17, 2019 at 11:05 nmr 4,5672 gold badges17 silver badges25 bronze badges asked Aug 17, 2019 at 9:01 fastriverfastriver 32 bronze badges 01 Answer
Reset to default 0Again use the get_term_by()
function:
$curr_taxonomy = get_query_var('taxonomy');
$term = get_term_by( 'slug', get_query_var('term'), $curr_taxonomy );
if ( $term !== FALSE && $term->parent > 0 )
$parent_term = get_term_by('id', (int) $term->parent, $curr_taxonomy );
else
$parent_term = false;