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.001473s = very slow | 50000 times = 63.94s = 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.
Default: array()
The post to check. If not supplied.
Default: current post if used in the loop


Since 3.1.0 Introduced.

Code of has post format: wp-includes/post-formats.php WP 5.4.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 );

Related Functions

From tag: post format

No comments
        Log In . Register