Add comment_count to the posts table. Props donncha. fixes #1860

git-svn-id: https://develop.svn.wordpress.org/trunk@3104 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2005-11-16 06:29:36 +00:00
parent cae1b67170
commit 376a04e7de
6 changed files with 50 additions and 14 deletions

View File

@@ -1306,11 +1306,7 @@ function update_post_caches(&$posts) {
update_post_category_cache($post_id_list);
// Do the same for comment numbers
$comment_counts = $wpdb->get_results("SELECT comment_post_ID, COUNT( comment_ID ) AS ccount
FROM $wpdb->comments
WHERE comment_post_ID IN ($post_id_list)
AND comment_approved = '1'
GROUP BY comment_post_ID");
$comment_counts = $wpdb->get_results( "SELECT ID as comment_post_ID, comment_count as ccount FROM $wpdb->posts WHERE ID in ($post_id_list)" );
if ( $comment_counts ) {
foreach ($comment_counts as $comment_count) {