Uses
Uses | Description |
---|---|
wp-includes/category-template.php: has_term() | Checks if the current post has any of given terms. |
wp-includes/formatting.php: sanitize_key() | Sanitizes a string key. |
Check if a post has any of the given formats, or any format.
(string|array) (Optional) The format or formats to check.
Default value: array()
(WP_Post|int|null) (Optional) The post to check. Defaults to the current post in the loop.
Default value: null
(bool) True if the post has any of the given formats (or any format, if no format specified), false otherwise.
$format = has_post_format($format, $post_id);
File: wp-includes/post-formats.php
function has_post_format( $format = array(), $post = null ) { $prefixed = array(); if ( $format ) { foreach ( (array) $format as $single ) { $prefixed[] = 'post-format-' . sanitize_key( $single ); } } return has_term( $prefixed, 'post_format', $post ); }
Version | Description |
---|---|
3.1.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/has_post_format