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:
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.