has_post_parent

函式
has_post_parent ( $post = null )
引數
  • (int|WP_Post|null) $post Optional. Post ID or WP_Post object. Default is global $post.
    Required:
    Default: null
返回值
  • (bool) Whether the post has a parent post.
定義位置
相關方法
get_post_parenthas_post_formatadd_posts_pagewp_get_post_parent_idupdate_post_parent_caches
引入
5.7.0
棄用
-

has_post_parent – 這是一個WordPress函式,用於檢查當前文章是否有一個父文章。父文章是用來在文章之間建立層次關係的,比如在建立頁面層次的時候。has_post_parent函式接受一個引數,即文章的ID或物件,如果該文章有一個父文章,則返回true,如果沒有,則返回false。

返回給定的文章是否有一個父文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function has_post_parent( $post = null ) {
return (bool) get_post_parent( $post );
}
function has_post_parent( $post = null ) { return (bool) get_post_parent( $post ); }
function has_post_parent( $post = null ) {
	return (bool) get_post_parent( $post );
}

常見問題

FAQs
檢視更多 >