This snippet allow you to show the most commented posts list between to dates without plugins. This code gets a DB query, and you need to specify in the snippet the beginning date and the ending date.
You can publish directly in sidebar or wherever you want. Continue reading
<ul>
<?php
$result = $wpdb->get_results("SELECT comment_count,ID,post_title, post_date FROM $wpdb->posts WHERE post_date BETWEEN 'YEAR-MM-DD (start)' AND 'YEAR-MM-DD (end)' ORDER BY comment_count DESC LIMIT 0 , 10");
foreach ($result as $topten) {
$postid = $topten->ID;
$title = $topten->post_title;
$commentcount = $topten->comment_count;
if ($commentcount != 0) {
?>
<li></li>
<?php }
}
?>
</ul>
Pingback: WordPress Code Snippets and Detailed Tutorials | eXpand yOur cReativity
Pingback: 19 Useful Wordpress Snippets & Tutorials - Design Freebies
Pingback: 21 Fresh WordPress Code Snippets and Detailed Tutorials : Web design