cat_is_ancestor_of

函式
cat_is_ancestor_of ( $cat1, $cat2 )
引數
  • (int|object) $cat1 ID or object to check if this is the parent category.
    Required:
  • (int|object) $cat2 The child category.
    Required:
返回值
  • (bool) Whether $cat2 is child of $cat1.
定義位置
相關方法
term_is_ancestor_ofget_post_ancestors_get_post_ancestorsget_ancestorshas_custom_logo
引入
2.1.0
棄用
-

cat_is_ancestor_of: 這個函式用來檢查一個類別是否是另一個類別的祖先。它需要兩個引數:子類別ID和父類別ID。它返回一個布林值,表明父類別是否是子類別的祖先。

檢查一個類別是否是另一個類別的祖先。

你可以使用ID或者類別物件作為兩個引數。如果你使用一個整數,類別將被檢索出來。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function cat_is_ancestor_of( $cat1, $cat2 ) {
return term_is_ancestor_of( $cat1, $cat2, 'category' );
}
function cat_is_ancestor_of( $cat1, $cat2 ) { return term_is_ancestor_of( $cat1, $cat2, 'category' ); }
function cat_is_ancestor_of( $cat1, $cat2 ) {
	return term_is_ancestor_of( $cat1, $cat2, 'category' );
}

常見問題

FAQs
檢視更多 >