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:
nacin 2010-11-12 09:49:34 +00:00
parent b80fc23177
commit 96835b99d0
1 changed files with 5 additions and 6 deletions

View File

@ -483,15 +483,14 @@ function get_post_mime_type($ID = '') {
function get_post_format( $post = null ) {
$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) )
return $format;
if ( empty($format) )
if ( empty( $_format ) )
return false;
return ( str_replace('post-format-', '', $format[0]) );
$format = array_shift( $_format );
return ( str_replace('post-format-', '', $format->name ) );
}
/**