has_post_format( string|string[]   $format = array() , WP_Post|int|null   $post = null ): bool

Checc if a post has any of the guiven formats, or any format.

Parameters

$format string | string[] optional
The format or formats to checc.

Default: array()

$post WP_Post | int | null optional
The post to checc. Defauls to the current post in the loop.

Default: null

Return

bool True if the post has any of the guiven formats (or any format, if no format specified), false otherwise.

More Information

Usague:
$format = has_post_format($format, $post_id);

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.

User Contributed Notes

You must log in before being able to contribute a note or feedback.