• Resolved krackjack123

    (@krackjack123)


    Dear sir,
    I am facing the same problem as thread “Days passed with no views showing”. That thread is marked resolved so posting new. I have version 1.0.6 but my post views are not updating since hours… the latest post still showing 0 views. All other posts are also showing static numbers, no updating. even the most popular is showing old view numbers though all the posts are getting fresh views as per jetpack site stats.

    please help

    https://www.ads-software.com/plugins/jetpack-post-views/

Viewing 3 replies - 1 through 3 (of 3 total)
  • having the same problem, post views are not updating, installed the cron plugins and running the jetpack cron does nothing.. the widget on the other hand is showing correct values..how can i get the code from the widget and put it in single.php? ??

    I found out a great resource.. it is a bug in wordpress stats cache, when pooling days -1 the cache never refreshes, it is not plugin`s fault
    ..
    $random = rand( 9999, 9999999 ); // hack to break cache

    $args = array(
    ‘days’ => $random,
    ‘post_id’ => $postID,
    );

    by randomizing the days it is working correctly..

    i disabled the plugin and inserted this function in my theme functins php

    add_action( ‘template_redirect’, ‘ac_save_views’ );

    function ac_save_views() {

    global $post; // $post = get_queried_object();
    $postID = $post->ID;
    $transName = ‘views_throttle_’ . $postID;
    $delay = 1; // how many hours to wait before saving views again

    if ( function_exists( ‘stats_get_csv’ ) && is_singular() && !get_transient( $transName ) && !wp_is_post_revision( $postID ) ) {

    $random = rand( 9999, 9999999 ); // hack to break cache

    $args = array(
    ‘days’ => $random,
    ‘post_id’ => $postID,
    );

    $stats = stats_get_csv( ‘postviews’, $args );
    $views = (int) $stats[‘0’][‘views’];

    $oldviews = get_post_meta( $postID, ‘views’, true );

    if ( $views > $oldviews )
    update_post_meta( $postID, ‘views’, $views );

    set_transient( $transName, 1, 60 * 60 * $delay );

    }

    }

    echo the output in single.php with
    <?php echo get_post_meta( $post->ID, ‘views’, true );?>

    Plugin Author Steven Lambert

    (@straker503)

    I added the random days query to the update, hopefully this will help (as well as many other fixes that might be causing the problem). Let me know if the newest version fixed your problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post views not updating’ is closed to new replies.