Hi, I just try to write a function to show top posts on the main blog for WPMU but it doesn’t work. What am I doing wrong? Here is the code. <?php function featured_posts(){ global $wpdb; $date = date('Y-m-d', strtotime('-1 months')); $date2 = date('Y-m-d', strtotime('-1000 days')); $days = (strtotime($date2) - strtotime($date)) / (60 * 60 * 24); $duration = $days; $request = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments"; $request .= " 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 "; $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $popularpostnumber"; $posts = $wpdb->get_results($wpdb->prepare($request)); if ($posts): echo '<ul>'; foreach ($posts as $post): setup_postdata($post); $post_title = stripslashes($post->post_title); $comment_count = $post->comment_count; $permalink = get_permalink($post->ID); echo '<li><a href="' . $permalink . '" title="' . $post_title.'"><span class="entry">' . $post_title . ' <span class="details inline">(' . $comment_count.')</span></span></a></li>'; endforeach; echo '</ul>'; else: _e("Didn't find any featured posts"); endif; } ?> Code (markup):