has_post_format(). see #14746

git-svn-id: https://develop.svn.wordpress.org/trunk@15778 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-10-12 19:25:58 +00:00
parent b1beb9c211
commit 0ccec0d6f1
1 changed files with 15 additions and 0 deletions

View File

@ -491,6 +491,21 @@ function get_post_format( $post ) {
return ( str_replace('post-format-', '', $format[0]) );
}
/**
* Check if a post has a particular format
*
* @since 3.1
*
* @uses has_term()
*
* @param string $format The format to check for
* @param object|id $post The post to check. If not supplied, defaults to the current post if used in the loop.
* @return bool True if the post has the format, false otherwise.
*/
function has_post_format( $format, $post = null ) {
return has_term('post-format-' . sanitize_key($format), 'post_format', $post);
}
/**
* Assign a format to a post
*