mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
Use term cache in get_post_format() to save a boatload of queries. see #15396.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b80fc23177
commit
96835b99d0
@ -483,15 +483,14 @@ function get_post_mime_type($ID = '') {
|
|||||||
function get_post_format( $post = null ) {
|
function get_post_format( $post = null ) {
|
||||||
$post = get_post($post);
|
$post = get_post($post);
|
||||||
|
|
||||||
$format = wp_get_object_terms( $post->ID, 'post_format', array('orderby' => 'none', 'fields' => 'names') );
|
$_format = get_the_terms( $post->ID, 'post_format' );
|
||||||
|
|
||||||
if ( is_wp_error($format) )
|
if ( empty( $_format ) )
|
||||||
return $format;
|
|
||||||
|
|
||||||
if ( empty($format) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return ( str_replace('post-format-', '', $format[0]) );
|
$format = array_shift( $_format );
|
||||||
|
|
||||||
|
return ( str_replace('post-format-', '', $format->name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user