get_post_type( int|WP_Post|null $post = null )

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


Description Description


Parameters Parameters

$post

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

Default value: null


Top ↑

Return Return

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


Top ↑

Source Source

File: wp-includes/post.php

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

	return false;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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