WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
[resolved] View count only updating when W3 total Chace caches are cleared (8 posts)

  1. Morten Ross
    Member
    Posted 1 month ago #

    Hi,

    I've seen and followed suggestions in this thread to no avail: http://wordpress.org/support/topic/all-time-view-count-not-working?replies=8

    Ajaxify widget enabled does not seem to work.

    Please advise.

    Regards
    Morten

    https://wordpress.org/plugins/wordpress-popular-posts/

  2. Héctor Cabrera
    Member
    Plugin Author

    Posted 1 month ago #

    Hi Morten, long time no see!

    Can you please post your site's URL?

  3. Morten Ross
    Member
    Posted 1 month ago #

  4. Héctor Cabrera
    Member
    Plugin Author

    Posted 1 month ago #

    Thanks! Just checked your site and it's working for me (screen capture).

  5. Morten Ross
    Member
    Posted 1 month ago #

    Hi,

    Interesting - I didn't test that scenario - that is working for me as well.

    The problem is in the post - the counter is not updating.

  6. Héctor Cabrera
    Member
    Plugin Author

    Posted 1 month ago #

    Ah, that makes more sense: you're talking about the wpp_get_views() template tag. You got me worried for a moment hehe.

    Anyways, the problem is that the entire post page is being cached - including the views count. This is something that WPP cannot prevent as of now (not even the older versions, actually) since W3TC is caching everything.

    While I'm not entirely familiar with W3TC, I know they had something called fragment caching. With it, W3TC allowed users to keep portions of a given page dynamic. I'm not sure if this feature is still available or not, but if it is then you could try something like this to solve the issue:

    1. Add this to your wp-config.php file: define('W3TC_DYNAMIC_SECURITY', 'E7C5F12EBCDA5F83A41BF33D778ED' );, where E7C5F12EBCDA5F83A41BF33D778ED is a random string that serves as a security key, I suppose.
    2. Then, in your single.php file change your code so it looks something like this:
      <!-- mfunc E7C5F12EBCDA5F83A41BF33D778ED
          echo wpp_get_views( get_the_ID() ) . " views";
      -->
      <!--/mfunc E7C5F12EBCDA5F83A41BF33D778ED -->

    You can see more on this workaround here.

    Give it a try and let me know what happens, alright?

    Edit: apparently, the wp-config part isn't really necessary according to this comment. That user also linked to this other comment with a sample code that apparently works fine (and also explains a bit more how to use fragment caching).

  7. Morten Ross
    Member
    Posted 1 month ago #

    OK - many thanks for your clarification and suggestions.

    My main concern was that the counter was not updated at all after plugin update, but it is as I can see when I'm logged in as Admin, the counter in all posts are correctly updated from the very last visit, as Admin is excluded from cache.

    Thanks for your speedy and detailed responses! And of course for a great plugin :-)

    Morten

  8. Héctor Cabrera
    Member
    Plugin Author

    Posted 1 month ago #

    No problem, I'm glad to be of any help!

Reply

You must log in to post.

About this Plugin

About this Topic