Count only approved comments. Props Mark JAquith. fixes #1930

git-svn-id: http://svn.automattic.com/wordpress/trunk@3192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-11-22 03:40:32 +00:00
parent a9d801767f
commit 0d31fcbeef
1 changed files with 1 additions and 1 deletions

View File

@ -302,7 +302,7 @@ function upgrade_160() {
}
// populate comment_count field of posts table
$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments GROUP BY comment_post_ID" );
$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
if( is_array( $comments ) ) {
foreach ($comments as $comment) {
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );