wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



has_post_format › WordPress Function

Depuis3.1.0
Dépréciéen/a
has_post_format ( $format = array(), $post = null )
Paramètres: (2)
  • (string|string[]) $format Optional. The format or formats to check. Default empty array.
    Requis: Non
    Défaut: array()
  • (WP_Post|int|null) $post Optional. The post to check. Defaults to the current post in the loop.
    Requis: Non
    Défaut: null
Retourne:
  • (bool) True if the post has any of the given formats (or any format, if no format specified), false otherwise.
Défini(e) dans:
Codex:

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



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