A WordPress-centric search engine for devs and theme authors



get_post_type ›

Since2.1.0
Deprecatedn/a
get_post_type ( $post = null )
Parameters:
  • (int|WP_Post|null) $post Optional. Post ID or post object. Default is global $post.
    Required: No
    Default: null
Returns:
  • (string|false) Post type on success, false on failure.
Defined at:
Codex:

Retrieves the post type of the current post or of a given post.



Source

function get_post_type( $post = null ) {
	if ( $post = get_post( $post ) ) {
		return $post->post_type;
	}

	return false;
}