wp_update_term_count fixes from cavemonkey50. fixes #4500
git-svn-id: http://svn.automattic.com/wordpress/trunk@5866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7c1ce10fae
commit
638d5e6e39
|
@ -789,12 +789,14 @@ function wp_update_term_count( $terms, $taxonomy ) {
|
|||
$terms = array_map('intval', $terms);
|
||||
|
||||
$taxonomy = get_taxonomy($taxonomy);
|
||||
if ( isset($taxonomy->update_count_callback) )
|
||||
if ( !empty($taxonomy->update_count_callback) )
|
||||
return call_user_func($taxonomy->update_count_callback, $terms);
|
||||
|
||||
// Default count updater
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
|
||||
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
|
||||
foreach ($terms as $term) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'");
|
||||
$wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue