Introduce is_post_type(). Can check if a post type is registered, or also if a post (current or specified) is of a certain post type. fixes #12588, props sirzooro, blepoxp, rmccue

git-svn-id: http://svn.automattic.com/wordpress/trunk@14158 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-04-18 17:40:50 +00:00
parent a1c0cee221
commit e47e3cc31c

View File

@ -668,6 +668,21 @@ function is_post_type_hierarchical( $post = false ) {
return false;
}
/**
* Checks if a post type is registered, can also check if the current or specified post is of a post type.
*
* @since 3.0.0
* @uses get_post_type()
*
* @param string|array $types Type or types to check. Defaults to all post types.
* @param int $id Post ID. Defaults to current ID.
* @return bool
*/
function is_post_type( $types = false, $id = false ) {
$types = ( $types === false ) ? get_post_types() : (array) $types;
return in_array( get_post_type( $id ), $types );
}
/**
* Retrieve the post type of the current post or of a given post.
*