WordPress开发者和主题制作者的搜索引擎



get_post_type_object ›

Since3.0.0
已弃用n/a
get_post_type_object ( $post_type )
参数:
  • (string) $post_type The name of a registered post type.
    Required: Yes
查看:
返回:
  • (WP_Post_Type|null) WP_Post_Type object if it exists, null otherwise.
定义在:
文档:
Change Log:
  • 4.6.0

Retrieves a post type object by name.



源码

function get_post_type_object( $post_type ) {
	global $wp_post_types;

	if ( ! is_scalar( $post_type ) || empty( $wp_post_types[ $post_type ] ) ) {
		return null;
	}

	return $wp_post_types[ $post_type ];
}