"; $after=""; $show_pass_post=''; $duration=''; global $wpdb; $hottopics = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments"; $hottopics .= " WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'"; if(!$show_pass_post) $request .= " AND post_password =''"; if($duration !="") { $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date "; } $hottopics .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $numtodisplay"; $hotposts = $wpdb->get_results($hottopics); $return = ''; if ($hotposts) { foreach ($hotposts as $hotpost) { $hotpost_title = stripslashes($hotpost->post_title); $comment_count = $hotpost->comment_count; $permalink = get_permalink($hotpost->ID); $return .= $before . '' . $post_title . ' (' . $comment_count.')' . $after; } } else { $return .= $before . "No hot topics found" . $after; } echo $return; ?>