WordPress at a glance

get_post_type() WP 1.0

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

Works based on: get_post()
✈ 1 time = 0.000637s = slow | 50000 times = 0.17s = very fast PHP 7.1.2, WP 4.7.5

No Hooks.


String/false. Post type on success, false on failure.


get_post_type( $post );
Post ID or post object.
Default: global $post

Code of get_post_type: wp-includes/post.php VER 5.0.1

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

	return false;

Related Functions

From tag: Custom post type (post_type)

More from category: Custom Types

No comments
    Hello, !     Log In . Register