From 58379895e523a6973df3ccb41b794788e6ecab8d Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 25 Aug 2011 18:49:46 +0000 Subject: [PATCH] Support fields = slugs in wp_get_object_terms(). Props lancewillett, SergeyBiryukov. fixes #15835 git-svn-id: http://svn.automattic.com/wordpress/trunk@18603 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index e1a4c353d..5f7fa4dc5 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -1893,6 +1893,8 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { $select_this = 't.term_id'; else if ( 'names' == $fields ) $select_this = 't.name'; + else if ( 'slugs' == $fields ) + $select_this = 't.slug'; else if ( 'all_with_object_id' == $fields ) $select_this = 't.*, tt.*, tr.object_id'; @@ -1901,7 +1903,7 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { if ( 'all' == $fields || 'all_with_object_id' == $fields ) { $terms = array_merge($terms, $wpdb->get_results($query)); update_term_cache($terms); - } else if ( 'ids' == $fields || 'names' == $fields ) { + } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) { $terms = array_merge($terms, $wpdb->get_col($query)); } else if ( 'tt_ids' == $fields ) { $terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");