admin管理员组文章数量:1415653
$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;
本文标签: How do I show the parent term on a custom taxonomy template (not the ID)
版权声明:本文标题:How do I show the parent term on a custom taxonomy template (not the ID)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745234687a2648981.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论