Advertisement
Guest User

Untitled

a guest
May 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. global $wpdb, $post;
  3. $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");
  4. echo $before_widget;
  5. echo $before_title . $mc_name . $after_title;
  6. echo "<ul> ";
  7. foreach ($mostcommenteds as $post) {
  8. $post_title = htmlspecialchars(stripslashes($post->post_title));
  9. $comment_total = (int) $post->comment_total;
  10. echo "<li><a href=\"" . get_permalink() . "\">$post_title&nbsp;<strong>($comment_total)</strong></a></li>";
  11. }
  12. echo "</ul> ";
  13. echo $after_widget;
  14. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement