• Resolved TrueLie

    (@footballher0)


    First of all, thank you for the plugin, excellent implementation and great features, very helpful)))

    Need help. To display the counter of post views, I took the shortcode published here, removing the restriction for single entries from it:

    function wpp_views_count_func() {
        if (
            function_exists('wpp_get_views')
        ) {
            $views_count = wpp_get_views( get_the_ID() );
            return ($views_count == 1) ? '1' : $views_count . '';
        }
    
        return '';
    }
    add_shortcode( 'wpp_views_count', 'wpp_views_count_func' );
    

    I put a counter on the main page, in the archives, and in single entries, and in General everything works correctly. But I noticed that sometimes there are records in which the counter remains equal to 1, although I see more than 1000 views in the statistics. I don’t see any errors in the console.

    I will be grateful for any hint. Can you tell me what information I can provide to diagnose the problem?

    • This topic was modified 4 years, 9 months ago by TrueLie.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @footballher0,

    Nothing seems out of place to me, except I would change:

    $views_count = wpp_get_views( get_the_ID() );
    return ($views_count == 1) ? '1' : $views_count . '';

    for:

    return wpp_get_views( get_the_ID() );

    Thread Starter TrueLie

    (@footballher0)

    Oh, thank you, that was the problem. Now everything works correctly)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problems with the shortcode of views’ is closed to new replies.