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: http://svn.automattic.com/wordpress/trunk@3193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0d31fcbeef
commit
24e2307445
|
@ -83,9 +83,10 @@ function wp_insert_comment($commentdata) {
|
||||||
|
|
||||||
$id = $wpdb->insert_id;
|
$id = $wpdb->insert_id;
|
||||||
|
|
||||||
if ( $comment_approved == 1)
|
if ( $comment_approved == 1) {
|
||||||
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count + 1 WHERE ID = '$comment_post_ID'" );
|
$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;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue