wp_get_term_taxonomy_parent_id

函数
wp_get_term_taxonomy_parent_id ( $term_id, $taxonomy )
参数
  • (int) $term_id Term ID.
    Required:
  • (string) $taxonomy Taxonomy name.
    Required:
返回值
  • (int|false) Parent term ID on success, false on failure.
定义位置
相关方法
wp_get_post_parent_idget_term_parents_list_wp_filter_taxonomy_basewp_nav_menu_item_taxonomy_meta_boxget_the_taxonomies
引入
3.1.0
弃用
-

wp_get_term_taxonomy_parent_id: 这个函数为分层分类法中的一个给定术语检索父术语ID。它只接受一个参数–术语ID。它返回父级术语ID,如果该术语没有父级,则返回0。

返回术语父的术语ID。

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;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-14 09:36:28

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: