Changeset 3311

Show
Ignore:
Timestamp:
12/15/05 20:31:29 (3 years ago)
Author:
ryan
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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'");