Title: Increase View Counts via PHP/JS
Last modified: August 30, 2016

---

# Increase View Counts via PHP/JS

 *  [cataful](https://wordpress.org/support/users/cataful/)
 * (@cataful)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/)
 * First of all, this is my favorite post view counter and I’ve tried all of them.
   Thank you for making an awesome plug in. Now my question…
 * is it possible to increase views manually with PHP and JS function/code?
 * [https://wordpress.org/plugins/post-views-counter/](https://wordpress.org/plugins/post-views-counter/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [dFactory](https://wordpress.org/support/users/dfactory/)
 * (@dfactory)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463089)
 * Yes, but did you try editing this in the edit post screen on the admin side? 
   PVC adds a new field to publish metabox where you can do that with ease for each
   post separately.
 * Regards
    Bartosz / dfactory
 *  Thread Starter [cataful](https://wordpress.org/support/users/cataful/)
 * (@cataful)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463102)
 * Yes I know about editing it on the admin side but I would like to do it with 
   PHP & Javascript as I want to attach it to the links the users click on.
 * For example, I have a RSS aggregator website. Each time the user click on the
   links that exits the website, I would like to manually add 1 view to the post
   that relates to the link. [I would like to attach a Javascript code to this]
 * Another would be me providing RSS feeds to my user. Example link: [http://www.mysite.com/ext/34305/](http://www.mysite.com/ext/34305/).
   When users click on that link, i would like to add a view to the post that relates
   to that link. [I would like to do this in PHP]
 * As you can see, when users click on the link, it won’t go to the post but actually
   exit the website. The links is related to the post so I would like to add a view
   to the post ID.
 * I would just like to know if there’s a function or way to easily add views to
   a post id via PHP and Javascript code. Thanks!
 *  Plugin Author [dFactory](https://wordpress.org/support/users/dfactory/)
 * (@dfactory)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463103)
 * These are good questions actually.
 * There is no out of the box mothod for this now. But we could provide one – just
   wondering how to do that in a flexible way.
 * One word about how it works: both PHP and JS modes fire similar (but not exactly
   the same) functions that first does multiple checks on whether the view should
   be counted or not. Then, if all the conditions are met (the viewer is not a robot,
   nor a logged out user, etc. depending on your settings) the cookie is being stored,
   and the counting function is fired, that performs the db query and handles object
   cache (if you have it enabled).
 * Now where would be the best point / moment for this? From what I think it would
   be just before or after saving the cookie to the browser. We could provide an
   action hook (one or more) here.
 * What you think?
 *  Thread Starter [cataful](https://wordpress.org/support/users/cataful/)
 * (@cataful)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463105)
 * > From what I think it would be just before or after saving the cookie to the
   > browser
 * Honestly, I’m not sure what’s the best way to do this as my programming skills
   aren’t that great. Whatever you decide would work best 🙂
 * Thanks for listening to my request!
 *  [sbdurham](https://wordpress.org/support/users/sbdurham/)
 * (@sbdurham)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463274)
 * I’m looking for this option, too. Using WP REST API to retrieve all post data.
   On this site WordPress doesn’t handle rendering views at all, and therefore no
   view is logged. I need a way to log a view every time the `article` endpoint 
   is hit.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Increase View Counts via PHP/JS’ is closed to new replies.

 * ![](https://ps.w.org/post-views-counter/assets/icon-256x256.png?rev=2973820)
 * [Post Views Counter](https://wordpress.org/plugins/post-views-counter/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-views-counter/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-views-counter/)
 * [Active Topics](https://wordpress.org/support/plugin/post-views-counter/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-views-counter/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-views-counter/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [sbdurham](https://wordpress.org/support/users/sbdurham/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/increase-view-counts-via-phpjs/#post-6463274)
 * Status: not resolved