Check if a post has any of the given formats, or any format.
$formatstring|string[]optional
Default:array()
$postWP_Post|int|nulloptional
Default:null
$format = has_post_format($format, $post_id); 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–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/has_post_format