get_post_type_object() – Retrieves a post type object by name.

You appear to be a bot. Output may be restricted

Description

Retrieves a post type object by name.

Usage

$WP_Post_Type|null = get_post_type_object( $post_type );

Parameters

$post_type
( string ) required – The name of a registered post type.

Returns

WP_Post_Type|null WP_Post_Type object if it exists, null otherwise.

Source

File name: wordpress/wp-includes/post.php
Lines:

1 to 9 of 9
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 ];
}
 

 View on GitHub View on Trac