返回术语的父级term_ID。
原型
wp_get_term_taxonomy_parent_id( int $term_id, string $taxonomy )
参数
$term_id
(int)
(Required)
术语ID。
$taxonomy
(string)
(Required)
分类名称。
返回值
(int|false)
错误时出错。
源文件
路径:wp-includes/taxonomy.php
<?php
...
function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
$term = get_term( $term_id, $taxonomy );
if ( ! $term || is_wp_error( $term ) ) {
return false;
}
return (int) $term->parent;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_get_term_taxonomy_parent_id/