function get_post_format( $post = null ) {}

Retrieve the format slug for a post


  • int|object $post: A post

Return values

returns:The format if successful. False if no format is set. WP_Error if errors.

Source code

function get_post_format( $post = null ) {

	$post = get_post($post);

	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 = array_shift( $_format );

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



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: