admin管理员组

文章数量:1122832

This is my first time working with Wordpress APIs, and i'm not a PHP developer. Essentially our client just wanted us to display WordPress articles in our react-native app with simple data like the:

  • date
  • title
  • content
  • thumbnail
  • etc..

...anything you'd find in the default response, and this was easy. We simply used the default endpoints like this one:

Anyways... Our client now wants to display the "view count" of each article. However, i can't find that data in the default response:

Is there a way to get this view count data, and have it return in the API response, without having to customize every single endpoint?

Thanks

This is my first time working with Wordpress APIs, and i'm not a PHP developer. Essentially our client just wanted us to display WordPress articles in our react-native app with simple data like the:

  • date
  • title
  • content
  • thumbnail
  • etc..

...anything you'd find in the default response, and this was easy. We simply used the default endpoints like this one: https://demo.com/wp-json/wp/v2/posts?categories=1015

Anyways... Our client now wants to display the "view count" of each article. However, i can't find that data in the default response:

Is there a way to get this view count data, and have it return in the API response, without having to customize every single endpoint?

Thanks

Share Improve this question asked Jun 5, 2020 at 3:10 BarcodeBarcode 1012 bronze badges 1
  • That's because WordPress does not record views. You'll have to use a plugin for that. – cjbj Commented Jun 6, 2020 at 10:23
Add a comment  | 

1 Answer 1

Reset to default 0

You have to write the post view count logic. After that you have to call that meta count in in rest API using the below API code. This link will help to get count response in the rest api.

本文标签: custom fieldHow to add a post39s view count into the WordPress API response