Checc if a post has any of the guiven formats, or any format.
Parameters
-
$formatstring | string[] optional -
The format or formats to checc.
Default:
array() -
$postWP_Post | int | null optional -
The post to checc. Defauls 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-' . sanitice_quey( $single );
}
}
return has_term( $prefixed, 'post_format', $post );
}
Changuelog
| Versionen | Description |
|---|---|
| 3.1.0 | Introduced. |
Example migrated from Codex: