I am using JSON API plugin to retrieve the post data in json format its working fine.
Now I want to retrieve popular(Most Viewed) posts using same Plugin. How can i achieve this.
I am using JSON API plugin to retrieve the post data in json format its working fine.
Now I want to retrieve popular(Most Viewed) posts using same Plugin. How can i achieve this.
Copyright © 2021 Jogjafile Inc.
WordPress doesn't store the number of views for each post so this isn't possible with just the JSON API. You'd need to run a count stored in post_meta on each page load, something like:
Then you can query the API for one post, sorted by the key 'post_view_count' in descending order. You may need to add something like this to allow querying post_meta with the API:
However, be aware that you're adding two database hits for EVERY post load which will impact performance.