[英]Plugin WordPress JSON API - How get posts for category with offset?
for example in category "news" of my blog there are 50 posts. 例如,在我的博客的“新闻”类别中有50个帖子。 For get last 10 posts I do: http://mywordpress.com/?json=get_category_posts&slug=news&count=10&status=publish And it work correctly.
要获得最近10篇帖子,请访问: http : //mywordpress.com/?json = get_category_posts & slg = news & count = 10&status = publisher并且它可以正常运行。 Now I want to get my posts from 11 to 20 skipping last 10 posts, etc. How can I do?
现在我想让我的帖子从11到20跳过最后10个帖子等等。我该怎么办?
The post count defaults to whatever you set in the wordpress backend (settings -> reading). 帖子计数默认为您在wordpress后端设置的任何内容(设置 - >阅读)。 You can achieve pagination by just adding the page parameter.
只需添加page参数即可实现分页。 So if you want the posts 11-20 you just call
所以,如果你想要帖子11-20,你只需要打电话
http://mywordpress.com/?json=get_category_posts&slug=news&count=10&status=publish&page=2
You find more information here: JSON API Plugin Page, Other Notes 您可以在此处找到更多信息: JSON API插件页面,其他Notes
You can't use get_category_posts with offset. 您不能将get_category_posts与偏移量一起使用。
You have to construct the query from the basic get_posts which has a lot of parameters, see here: 您必须从具有大量参数的基本get_posts构造查询,请参见此处:
http://codex.wordpress.org/Class_Reference/WP_Query#Parameters http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
and here (read Method: get_posts): 在这里(阅读方法:get_posts):
http://wordpress.org/plugins/json-api/other_notes/ http://wordpress.org/plugins/json-api/other_notes/
I think you should use something like: 我认为你应该使用类似的东西:
blablabla.xxx/?json=get_posts&count=10&status=published&cat='id of the category news'&offset='int offset'
blablabla.xxx/?json=get_posts&count=10&status=published&cat='id of category news'&offset ='int offset'
Be aware that use offset 'breaks' pagination 请注意使用偏移“中断”分页
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.