Support » Plugin: Popular Posts Tabbed Widget for Jetpack » POPULAR TODAY shows "Sorry. No data yet."

  • Resolved Jerichos


    I’m facing a problem with Popular Posts Tabbed Widget. In Popular today it shows “Sorry. No data yet.” for some time. It happens because my website’s time zone is not far the same as my local computer’s time zone.

    In Jetpack stats it shows 25 June, and my local date is already 26 June for 6 hours. I suppose visitors from different countries are facing the same problem as I do.

    So, I Think the problem is in date, but personally I can not handle this issue. Could you please help me with that.

    Thank you!

    Best Regards.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Ryann Micua


    Hi Jerichos,

    Have you tried setting Popular Posts date range to Monthly instead of daily? Hopefully that should alleviate the issue a bit. Clicking on “Today” may still show the “no data” text.

    Also in your WordPress’ site date, you could try to set it to your timezone or something.

    Yes, I’ve tried to set Date range to weekly and it works just fine, but I think that visitors, who live to West from my WordPress time zone will face the same problem if they click Today’s popular news.

    Thank you.

    Is it possible to pick date from my WordPress instead of my local date?

    Thank you.

    Plugin Author Ryann Micua


    Yes, like I said, the today thing will have a problem and I really can’t do much about it since the stats are taken from jetpack stats. So, if there are no stats for today from jetpack then there will be nothing to show. I’ll probably add an option to set the “today” to actaully be 2 days later on.

    Not sure what you mean about your 2nd question.

    The thing is that jetpack shows Today’s top posts without any problem, but this plugin tries to get top list from the next day if user’s local date is after WordPress timezone’s date.

    In my last post I meant something like to get jetpack’s day’s top posts using it’s own function now() or something. I don’t know how to do it, i’m just suggesting)))

    I made this widget to work satisfactorily by changing my wordpress local timezone to UTC+14.

    Thank you for your responds.

    Plugin Author Ryann Micua


    uh, that’s what I suggested in my first reply – change your timezone. Jetpack’s Today’s top posts *should* be the same as in the popular plugin. Reason for that is because the plugin is just using the same functions as what jetpack itself uses.

    Jetpack’s Today’s top posts *should* be the same as in the popular plugin

    But it’s not because it depends on date of my computer.

    Ok, I changed WordPress timezone to my local timezone, which is currently UTC+3 and it works just fine for me. But if I were in Kiritimati, Christmas Island, Kiribati (UTC/GMT +14) there would be 27 June already.

    In my admin panel I can see all popular news for today (for me it’s 26 June right now), but if I change date on my device to 27 June (which is true for Kiritimati) and try to access my web page, plugin shows “Sorry. No data yet.”.

    Changing timezone in WordPress settings to UTC +14 is not a very good idea as well, because the opposite thing happens – it shows popular posts, indeed, but for me it shows yesterday’s most popular stats.

    Problem resolved by changing WordPress timezone to UTC+0 and changing function “now” at popular-posts-tab-widget-for-jetpack.php

    static function now(){
    		return current_time('mysql');

    to this

    static function now(){
    		return current_time('mysql', 1);

    now this function returns current server’s UTC time

    Thank you.

    Plugin Author Ryann Micua


    Thank you Jericho for taking the time to go through the code Jericho. Appreciate it.

    There’s just one thing though. This function:

    static function now(){
       return current_time('mysql');

    isn’t used anywhere for getting the list of popular posts. It’s only used for getting the list of most commented post 😉

    Since you can certainly read code, here’s the function that actually does the work on the popular posts tab:

     * Uses data gathered by Jetpack stats and stored in servers
    static function get_posts_by_wp_com( $args ){
    	if( !self::$_stats_enabled || !function_exists('stats_get_csv'))
    		return array();
    	$defaults = array(
    		'limit' => 5,
    		'range' => 'all', //daily|weekly|monthly|all
    		'post_type' => 'post',
    		'date_format' => get_option('date_format')
    	$args = wp_parse_args( (array) $args, $defaults );
    	$limit = intval( $args['limit'] );
    	/** TODO: limit $limit to 100? **/
    	$days = 2;
    	switch( $args['range'] ){
    		case 'weekly':  $days = 7; break;
    		case 'monthly': $days = 30; break;
    		case 'daily' :  $days = 1; break;
    		case 'all':
    		default:        $days = -1; break; //get all
    	/** we only limit to 50 posts. but change this if you want **/
    	$top_posts = stats_get_csv( 'postviews', array( 'days' => $days, 'limit' => 50 ) );
    	if( !$top_posts ){
    		return array();
    	/** Store post_id into array **/
    	$post_view_ids = array_filter( wp_list_pluck( $top_posts, 'post_id' ) );
    	if ( !$post_view_ids ) {
    		return array();
    	// cache
    	get_posts( array( 'include' => join( ',', array_unique( $post_view_ids ) ) ) );
    	// return posts list
    	$posts = array();
    	$counter = 0;
    	foreach( $top_posts as $top_post ){
    		//should only trigger for homepage
    		$post = get_post( $top_post['post_id'] );
    		if ( !$post )
    		if( $args['post_type'] != $post->post_type )
    		$permalink = get_permalink( $post->ID );
    		$postdate = date_i18n( $args['date_format'], strtotime( $post->post_date ) );
    		$views = number_format_i18n( $top_post['views'] );
    		if ( empty( $post->post_title ) ) {
    			$title_source = $post->post_content;
    			$title = wp_html_excerpt( $title_source, 50 );
    			$title .= '…';
    		} else {
    			$title = $post->post_title;
    		$data = array(
    			'title' => $title,
    			'permalink' => $permalink,
    			'views' => $views,
    			'id' => $post->ID,
    			'postdate' => $postdate
    		$posts[] = $data;
    		if( $counter == $limit )
    	return $posts;

    The most relevant function call is this:

    $top_posts = stats_get_csv( 'postviews', array( 'days' => $days, 'limit' => 50 ) );

    stats_get_csv() is the function that grabs the popular posts from jetpack stats server. what the plugin then does is to remove the the non-blog-post pages leaving only blog posts.

    So, if you’re saying that it’s working now then it’s because you set your timezone to utc+0 – which I’m pretty sure is what jetpack stats is based off of – and not because you edited the now() function which has nothing to do with popular posts.

    I’m not so good at PHP, I work more with C#.
    I just looked at this query where function now is present

    /* RANGE: Daily */
    			// views
    			if ($args['order_by'] == "views" || $args['order_by'] == "avg" || $args['stats_tag']['views']) {
    				$join .= " LEFT JOIN (SELECT id, SUM(pageviews) AS 'pageviews', day FROM (SELECT id, pageviews, day FROM {$table}cache WHERE day > DATE_SUB('".self::now()."', INTERVAL 1 DAY) ORDER BY day) sv GROUP BY id) v ON p.ID = ";
    				$fields .= ", IFNULL(v.pageviews, 0) AS 'pageviews' ";

    Thank You.

    Plugin Author Ryann Micua


    actually, that’s unused code 😀 I was thinking of being able to integrate with one other *popular posts* plugin that’s why I left that option in there. but I can tell you right now, that section is unused.

    If you want to do a trace, start with this function:

    function widget($args, $instance)

    that’s what wp calls to display the actual widget markup in the frontend.

    and oh, I think c# is awesome.

    I think c# is awesome.

    I love it either =)))

    Anyway I Love your widget and now It look to work fine, Thanks

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘POPULAR TODAY shows "Sorry. No data yet."’ is closed to new replies.