wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



get_post_format › WordPress Function

Od3.1.0
Przestarzałyn/a
get_post_format ( $post = null )
Parametry:
  • (int|WP_Post|null) $post Optional. Post ID or post object. Defaults to the current post in the loop.
    Wymagane: Nie
    Domyślny: null
Powrót:
  • (string|false) The format if successful. False otherwise.
Zdefiniowane na:
Codex:

Retrieve the format slug for a post



Źródło

function get_post_format( $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	if ( ! post_type_supports( $post->post_type, 'post-formats' ) ) {
		return false;
	}

	$_format = get_the_terms( $post->ID, 'post_format' );

	if ( empty( $_format ) ) {
		return false;
	}

	$format = reset( $_format );

	return str_replace( 'post-format-', '', $format->slug );
}