get_post_type() – Retrieves the post type of the current post or of a given post.

You appear to be a bot. Output may be restricted

Description

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

Usage

$string|false = get_post_type( $post );

Parameters

$post
( int|WP_Post|null ) optional – Optional. Post ID or post object. Default is global $post.

Returns

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

Source

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

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

  return false;
}
 

 View on GitHub View on Trac