post_type_exists

函式
post_type_exists ( $post_type )
引數
  • (string) $post_type Post type name.
    Required:
返回值
  • (bool) Whether post type is registered.
相關
  • get_post_type_object()
定義位置
相關方法
post_existspost_type_supportsterm_existsget_post_typesget_post_type_object
引入
3.0.0
棄用
-

post_type_exists函式是一個WordPress函式,用來檢查一個自定義的文章型別是否在WordPress註冊。如果文章型別存在,它返回一個布林值:true;如果不存在,則返回false。

確定一個文章型別是否被註冊。

關於這個和類似主題函式的更多資訊,請檢視《主題開發者手冊》中的{@link Conditional Tags}文章。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function post_type_exists( $post_type ) {
return (bool) get_post_type_object( $post_type );
}
function post_type_exists( $post_type ) { return (bool) get_post_type_object( $post_type ); }
function post_type_exists( $post_type ) {
	return (bool) get_post_type_object( $post_type );
}

常見問題

FAQs
檢視更多 >