Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there,

    At the moment, no. WordPress Popular Posts lists all posts that have been viewed or commented in the selected time range – it doesn’t matter when they were first published.

    However, you could change the plugin’s code to limit the popular lists only to those posts published within the specified time range. For that, you need to change this:

    $query = "SELECT p.ID AS 'id', p.post_title AS 'title', p.post_date AS 'date', p.post_author AS 'uid' {$fields} FROM {$wpdb->posts} p {$join} WHERE p.post_status = 'publish' AND p.post_password = '' {$where} GROUP BY p.ID {$having} ORDER BY {$orderby} DESC LIMIT " . $instance['limit'] . ";";

    …into this:

    $post_interval = "";
    
    if ($instance['range'] == "daily") {
    	$post_interval = " AND post_date_gmt > DATE_SUB('".$this->now()."', INTERVAL 1 DAY) ";
    } else if ($instance['range'] == "weekly") {
    	$post_interval = " AND post_date_gmt > DATE_SUB('".$this->now()."', INTERVAL 1 WEEK) ";
    } else if ($instance['range'] == "monthly") {
    	$post_interval = " AND post_date_gmt > DATE_SUB('".$this->now()."', INTERVAL 1 MONTH) ";
    }
    
    $query = "SELECT p.ID AS 'id', p.post_title AS 'title', p.post_date AS 'date', p.post_author AS 'uid' {$fields} FROM {$wpdb->posts} p {$join} WHERE p.post_status = 'publish' AND p.post_password = '' {$where} {$post_interval} GROUP BY p.ID {$having} ORDER BY {$orderby} DESC LIMIT " . $instance['limit'] . ";";

    And save changes.

    Please note that I didn’t test the code as I’m a bit busy now, so you’ll have to do it yourself. Also, you’ll need to add this change each time the plugin gets updated and probably change a few things as this code might be obsolete in future releases.

    Thread Starter botakedan

    (@botakedan)

    awesome…
    will try this right away…

    Thread Starter botakedan

    (@botakedan)

    great, its works!!!
    may be you can add this on the next update 🙂

    thank you man…

    Any chances for implementing this in recent version of plugin?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi medraka,

    Yes, it’s already on the ToDo list (see issue).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WordPress Popular Posts] popular by day posts published’ is closed to new replies.