WordPress Version: 5.3
/**
* Retrieves the post type of the current post or of a given post.
*
* @since 2.1.0
*
* @param int|WP_Post|null $post Optional. Post ID or post object. Default is global $post.
* @return 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;
}