WordPress at a glance

has_post_format() WP 1.0

Check if a post has any of the given formats, or any format.

Works based on: has_term()
1 time — 0.001473 sec (very slow) | 50000 times — 63.94 sec (very slow)

No Hooks.


true|false. True if the post has any of the given formats (or any format, if no format specified), false otherwise.


has_post_format( $format, $post );
The format or formats to check.
The post to check.
Default: current post in the loop


Since 3.1.0 Introduced.

Code of has_post_format() WP 5.7.2

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 );

From tag: post format

No comments
    Log In