<?php
$now = gmdate("Y-m-d H:i:s",time());
$lastmonth = gmdate("Y-m-d H:i",gmmktime(date("H"), date("i"), date("s"), date("m")-1,date("d"),date("Y")));
$popularposts = "SELECT ID, post_title, post_date, comment_count, COUNT($wpdb->comments.comment_post_ID) AS 'popular' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND post_date > '$lastmonth' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY popular DESC LIMIT 5";
$posts = $wpdb->get_results($popularposts);
$popular = '';
if($posts){
foreach($posts as $post){
$post_title = stripslashes($post->post_title);
$post_date = stripslashes($post->post_date);
$comments = stripslashes($post->comment_count);
$guid = get_permalink($post->ID);
$popular .= '<li><a href="'.$guid.'" title="'.$post_title.'">'.$post_title.'</a>
<span>With <a href="'.$guid.'#commenting" title="Comments on '.$post_title.'">'.$comments.' Comments</a> Since '.$post_date.'</span></li>';
}
}echo $popular;
?>
This is the code. I’m not that good in editing php… I tried the plugin that you suggested, it’s good and it works BUT i’m not satisfied because it’s not the same as the theme’s default one.
The default popular function shows the text’s title and bellow shows the number of comments since a post publishing date.
The plugin you provided show the text’s title and number of comments next to it… Inb order to do the things the default popular theme does, it requires editing, and i am not that good at it.
So, can you or someone else look at the code, and say how to simply edit it to show posts with the largest amount of comments…