From dd66d9947785ea329f6c92ff2644b3e76e4ebfb1 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 2 Jun 2010 14:55:33 +0000 Subject: [PATCH] Make _pad_term_counts custom post type aware. Props reko. fixes #13670 git-svn-id: http://svn.automattic.com/wordpress/trunk@15108 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index d85c0237b..a4f5f389a 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2375,7 +2375,7 @@ function &_get_term_children($term_id, $terms, $taxonomy) { */ function _pad_term_counts(&$terms, $taxonomy) { global $wpdb; - +error_log("here $taxonomy"); // This function only works for hierarchical taxonomies like post categories. if ( !is_taxonomy_hierarchical( $taxonomy ) ) return; @@ -2393,7 +2393,9 @@ function _pad_term_counts(&$terms, $taxonomy) { } // Get the object and term ids and stick them in a lookup table - $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (".join(',', array_keys($term_ids)).") AND post_type = 'post' AND post_status = 'publish'"); + $tax_obj = get_taxonomy($taxonomy); + $object_types = esc_sql($tax_obj->object_type); + $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'"); foreach ( $results as $row ) { $id = $term_ids[$row->term_taxonomy_id]; $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;