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



get_post_type › WordPress Function

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 ) {
	$post = get_post( $post );
	if ( $post ) {
		return $post->post_type;
	}

	return false;
}