Hi wppit,
Someone else suggested this some time ago and I totally forgot about it. I’ll add this idea to my notes and see what I can do. No promises, though 😉
+1.
such a setting would be great!
Actually here is how to do it hacking into the plugin:
wordpress-popular-posts.php line 513 Replace this:
switch( $instance['range'] ) {
case 'all':
$range = "post_date_gmt < '".gmdate("Y-m-d H:i:s")."'";
break;
case 'yesterday':
$range = $table."cache.day >= '".gmdate("Y-m-d")."' - INTERVAL 1 DAY";
break;
case 'daily':
//$range = $table."cache.day = ".$this->curdate();
$range = $table."cache.day >= '".$this->now()."' - INTERVAL 1 DAY";
break;
case 'weekly':
$range = $table."cache.day >= '".gmdate("Y-m-d")."' - INTERVAL 7 DAY";
break;
case 'monthly':
$range = $table."cache.day >= '".gmdate("Y-m-d")."' - INTERVAL 30 DAY";
break;
default:
$range = "post_date_gmt < '".gmdate("Y-m-d H:i:s")."'";
break;
}
By this:
switch( $instance['range'] ) {
case 'all':
$range = "$wpdb->posts.post_date_gmt < '".gmdate("Y-m-d H:i:s")."'";
break;
case 'yesterday':
$range = "$wpdb->posts.post_date_gmt >= '".gmdate("Y-m-d")."' - INTERVAL 1 DAY";
break;
case 'daily':
//$range = $table."cache.day = ".$this->curdate();
$range = "$wpdb->posts.post_date_gmt >= '".current_time('mysql')."' - INTERVAL 1 DAY";
break;
case 'weekly':
$range = "$wpdb->posts.post_date_gmt >= '".gmdate("Y-m-d")."' - INTERVAL 7 DAY";
break;
case 'monthly':
$range = "$wpdb->posts.post_date_gmt >= '".gmdate("Y-m-d")."' - INTERVAL 30 DAY";
break;
default:
$range = "$wpdb->posts.post_date_gmt < '".gmdate("Y-m-d H:i:s")."'";
break;
}
Sorry for the code alignment above, basically you change this: $table.”cache.day
to this:
“$wpdb->posts.post_date_gmt
Where it is not looking at all the post in the cache but only the one within the range.
Also it is better to extract the whole function from the plugin and maybe build your own into you theme functions files to avoid conflict with plugin update.
I hope this helps.