Use term cache in get_post_format() to save a boatload of queries. see #15396.

git-svn-id: https://develop.svn.wordpress.org/trunk@16319 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-11-12 09:49:34 +00:00
parent 46efef4555
commit 8d5463366a
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 ) { 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 ) );
} }
/** /**