Fetch full terms for the post_category and tags_input queries and then wp_list_pluck() the desired fields. Fetching full terms primes the cache and reduces overall queries. Add cache invalidation to wp_set_post_terms(). Props scribu. see #21309

git-svn-id: http://core.svn.wordpress.org/trunk@21981 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren
2012-09-24 20:35:56 +00:00
parent 1924ec4117
commit 70edf4111b
2 changed files with 20 additions and 15 deletions

View File

@@ -1062,6 +1062,9 @@ function get_the_terms( $post, $taxonomy ) {
if ( ! $post = get_post( $post ) )
return false;
if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
return false;
$terms = get_object_term_cache( $post->ID, $taxonomy );
if ( false === $terms ) {
$terms = wp_get_object_terms( $post->ID, $taxonomy );