wp_update_term_count fixes from cavemonkey50. fixes #4500
git-svn-id: https://develop.svn.wordpress.org/trunk@5866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ebf9ab90b6
commit
9d8324b07b
|
@ -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
|
||||
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