Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $wpdb, $post;
- $mostcommenteds = $wpdb->get_results("SELECT $wpdb->posts.ID, post_title, post_name, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_total' FROM $wpdb->posts LEFT JOIN $wpdb->comments ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' AND post_status = 'publish' AND post_password = '' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_total DESC LIMIT $mc_number");
- echo $before_widget;
- echo $before_title . $mc_name . $after_title;
- echo "<ul> ";
- foreach ($mostcommenteds as $post) {
- $post_title = htmlspecialchars(stripslashes($post->post_title));
- $comment_total = (int) $post->comment_total;
- echo "<li><a href=\"" . get_permalink() . "\">$post_title <strong>($comment_total)</strong></a></li>";
- }
- echo "</ul> ";
- echo $after_widget;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement