Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi moodless,

    Nope, currently there’s no way to get yesterday’s most popular posts without affecting my plugin’s performance. I might include this feature in a future release, though, since the hack to achieve this is a bit more complicated than the usual requests.

    I’ll try a few things a post back here with instructions in case you want to try it out.

    Thanks for your feedback!

    Thread Starter moodless

    (@moodless)

    Thank you ikki24
    I will wait for your instructions ??

    Alright, here’s what you need to do:

    # On wordpress-popular-posts.php:

    Find:

    switch( $instance['range'] ) {
    	case 'all':
    		$range = "post_date_gmt < '".gmdate("Y-m-d H:i:s")."'";
    		break;
    	case 'daily':
    		$range = $table."cache.day = CURDATE()";
    		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;
    }

    … and replace it with:

    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 = CURDATE()";
    		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;
    }

    Find:

    // possible values for "Time Range" and "Order by"
    $range_values = array("daily", "weekly", "monthly", "all");

    … and replace it with:

    // possible values for "Time Range" and "Order by"
    $range_values = array("yesterday", "daily", "weekly", "monthly", "all");

    # On stats.php:

    Find:

    <div id="wpp-stats-tabs">
            <a href="#" class="button-primary" rel="wpp-daily"><?php _e("Today", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-weekly"><?php _e("Weekly", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-monthly"><?php _e("Monthly", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-all"><?php _e("All-time", "wordpress-popular-posts"); ?></a>
        </div>
        <div id="wpp-stats-canvas">
            <div class="wpp-stats wpp-stats-active" id="wpp-daily">
                <?php echo do_shortcode('[wpp range=today stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-weekly">
                <?php echo do_shortcode('[wpp range=weekly stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-monthly">
                <?php echo do_shortcode('[wpp range=monthly stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-all">
                <?php echo do_shortcode('[wpp range=all stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
        </div>

    … and replace it with:

    <div id="wpp-stats-tabs">
        	<a href="#" class="button-primary" rel="wpp-yesterday"><?php _e("Yesterday", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-daily"><?php _e("Today", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-weekly"><?php _e("Weekly", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-monthly"><?php _e("Monthly", "wordpress-popular-posts"); ?></a>
            <a href="#" class="button-secondary" rel="wpp-all"><?php _e("All-time", "wordpress-popular-posts"); ?></a>
        </div>
        <div id="wpp-stats-canvas">
            <div class="wpp-stats wpp-stats-active" id="wpp-yesterday">
                <?php echo do_shortcode('[wpp range=yesterday stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-daily">
                <?php echo do_shortcode('[wpp range=today stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-weekly">
                <?php echo do_shortcode('[wpp range=weekly stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-monthly">
                <?php echo do_shortcode('[wpp range=monthly stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
            <div class="wpp-stats" id="wpp-all">
                <?php echo do_shortcode('[wpp range=all stats_views=1 order_by=views wpp_start=<ol> wpp_end=</ol>]'); ?>
            </div>
        </div>

    That should do it ??

    Hi!

    I would like to use this plugin as a query string or something to power a custom loop I have on my site. I don’t really want to hack the plugin (I don’t know how either!), just use it’s info to display the most viewed posts in the last 7 days using my custom loop. Is this possible?

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Yastarday Most Popular Posts’ is closed to new replies.