今天在处理文章数据加载时候出现无法判断最大页码,于是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
领取专属 10元无门槛券
私享最新 技术干货