From 0ccec0d6f11fc30d595d4544e4db827175b7b4f7 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 12 Oct 2010 19:25:58 +0000 Subject: [PATCH] has_post_format(). see #14746 git-svn-id: https://develop.svn.wordpress.org/trunk@15778 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wp-includes/post.php b/wp-includes/post.php index 18e21302e0..3500080958 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 *