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。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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
檢視更多 >