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
1 Answer
Reset to default 0You 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
版权声明:本文标题:custom field - How to add a post's view count into the WordPress API response 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736286496a1927682.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论