Viewing 1 post (of 1 total)
  • Author
    Posts
  • #46814
    notatether
    Participant

    My theme has a trending posts widget which sorts posts by the post_view_count meta value. The problem with this, I found out, is that you can refresh the page repeatedly and increment the post_view_count that way. This causes the trending posts to look very distorted.

    So to fix this I am trying to extract the view count from this plugin into a new meta value. This snippet I made should do the trick for a given post ID and view count:

    update_post_meta((int) $post_id, "pvc_post_count", (int) $post_view);

    However, I do not know in which function I should place this in, since every one I try in the Plugin Editor doesn’t seem to make the changes take effect. I have tried logging trace messages to WordPress debug.log with debugging enabled but those messages don’t seem to be logged either. This leads me to think that WordPress is not honoring my code changes. Any suggestions? I’m not using wp-admin caching plugins.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.