WordPress Custom Query to get Most Commented Posts in the Past 7 Days
This should do it: $querystr = “SELECT comment_count, ID, post_title FROM $wpdb->posts wposts, $wpdb->comments wcomments WHERE wposts.ID = wcomments.comment_post_ID AND wposts.post_status=”publish” AND wcomments.comment_approved=’1′ AND wcomments.comment_date > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR) GROUP BY wposts.ID ORDER BY comment_count DESC LIMIT 0 , 10 “;