Check if a post has any of the given formats, or any format.
Parameters
$format
string|string[]optional- The format or formats to check.
Default:
array()
$post
WP_Post|int|nulloptional- The post to check. Defaults to the current post in the loop.
Default:
null
Source
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 ); }
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |
Example migrated from Codex: