wpseek.com
A WordPress-centric search engine for devs and theme authors



get_post_type_object › WordPress Function

Since3.0.0
Deprecatedn/a
get_post_type_object ( $post_type )
Parameters:
  • (string) $post_type The name of a registered post type.
    Required: Yes
See:
Returns:
  • (WP_Post_Type|null) WP_Post_Type object if it exists, null otherwise.
Defined at:
Codex:
Change Log:
  • 4.6.0

Retrieves a post type object by name.



Source

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 ];
}