在页面中我有学期 child 的 ID,我需要通过 child ID 找出这个 child 的 parent ,这是可以接受的,也许有人可以帮助解决这个问题?
最佳答案
这就是 get_term
的内容功能用于:
$term_id = 21; // Lucky number :)
$child_term = get_term( $term_id, 'category' );
$parent_term = get_term( $child_term->parent, 'category' );
将 'category'
替换为您正在使用的任何分类法。
关于php - Wordpress 通过 child ID 获取当前过期 parent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14591491/