From 77fe382c33f7bb86dc46e05092de3c0db28b5f04 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 15 Nov 2005 23:47:16 +0000 Subject: [PATCH] Move category post count updater into wp_set_post_cats(). git-svn-id: https://develop.svn.wordpress.org/trunk@3094 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions-post.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 277e7c5415..872c029399 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -168,13 +168,6 @@ function wp_insert_post($postarr = array()) { if ($post_status == 'publish') { do_action('publish_post', $post_ID); - // Update category counts. - foreach ( $post_category as $cat_id ) { - $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'"); - $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); - wp_cache_delete($cat_id, 'category'); - } - if ($post_pingback && !defined('WP_IMPORTING')) $result = $wpdb->query(" INSERT INTO $wpdb->postmeta @@ -481,6 +474,13 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array( VALUES ($post_ID, $new_cat)"); } } + + // Update category counts. + foreach ( $post_categories as $cat_id ) { + $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'"); + $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'"); + wp_cache_delete($cat_id, 'category'); + } } // wp_set_post_cats() function wp_delete_post($postid = 0) {