Instead of incrementing the current comment count, recount all comments to make sure we have a good count. Props Mark Jaquith. fixes #1920
git-svn-id: https://develop.svn.wordpress.org/trunk@3193 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6584fdf4ff
commit
e53912a4dd
@ -83,9 +83,10 @@ function wp_insert_comment($commentdata) {
|
||||
|
||||
$id = $wpdb->insert_id;
|
||||
|
||||
if ( $comment_approved == 1)
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count + 1 WHERE ID = '$comment_post_ID'" );
|
||||
|
||||
if ( $comment_approved == 1) {
|
||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
|
||||
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" );
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user