Changeset 6051
- Timestamp:
- 09/06/2007 10:56:03 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/upgrade.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/upgrade.php
r6039 r6051 674 674 675 675 // Recalculate all counts 676 $terms = $wpdb->get_ col("SELECT term_taxonomy_idFROM $wpdb->term_taxonomy");676 $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); 677 677 foreach ( (array) $terms as $term ) { 678 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term'"); 679 $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term'"); 678 if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) 679 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = '$term->term_taxonomy_id'"); 680 else 681 $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term->term_taxonomy_id'"); 682 $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term->term_taxonomy_id'"); 680 683 } 681 684 }
Note: See TracChangeset
for help on using the changeset viewer.