Make WordPress Core

Changeset 3311


Ignore:
Timestamp:
12/15/2005 08:31:29 PM (20 years ago)
Author:
ryan
Message:

When changing a post's categories, redo category counts for both old and new cats. Props ringmaster. fixes #2085

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r3303 r3311  
    505505   
    506506    // Update category counts.
    507     foreach ( $post_categories as $cat_id ) {
     507    $all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
     508    foreach ( $all_affected_cats as $cat_id ) {
    508509        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
    509510        $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
Note: See TracChangeset for help on using the changeset viewer.