get_post_type( int|WP_Post|null $post = null ): string|false

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


Post ID or post object. Default is global $post.



string|false Post type on success, false on failure.


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

	return false;



User Contributed Notes

  1. Skip to note 7 content

    Conditional sentence to see if it is a post type.

    if ( get_post_type( get_the_ID() ) == 'slug_post_type' ) {
        //if is true
  2. Skip to note 10 content

    is commonly used in conjunction with Post Formats.
    Functionality is extended in themes by including:
    add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
    in your functions.php file.

    After including this in your theme’s functions.php file, the option to choose a post type (that you included inside the array) will appear in the right sidebar when creating/editing a post.

    If no Post Type is selected, WordPress selects the default which is Standard.

    WordPress supported post formats (that are not defaults) are:
    'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'

    Everything you need to know about using & styling Post Formats is here:

You must log in before being able to contribute a note or feedback.