首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Get post count and TotalPages in wp rest API v2

今天在处理文章数据加载时候出现无法判断最大页码,于是google到的一些答案。

The WP Rest API sends the total count(found_posts) property from WP_Query. in a header called.

FOR POSTS:you can make a call to posts endpoint of the REST API

The value for posts count is returned in the header as. Below is a sample response from the hosted demo

这里具体使用实例:

参考文档:

wordpress官方文档(英语能力不行,当时没看懂~~): https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/

stackoverflow: https://stackoverflow.com/questions/48503413/wordpress-rest-api-get-total-post-count

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180316G1MWBL00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券