From d7538470506c04776068ea2de3bf398fc26a6918 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 12 Oct 2010 19:25:58 +0000 Subject: [PATCH] has_post_format(). see #14746 git-svn-id: http://svn.automattic.com/wordpress/trunk@15778 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/post.php b/wp-includes/post.php index 18e21302e..350008095 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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 *