简体   繁体   中英

Plugin WordPress JSON API - How get posts for category with offset?

for example in category "news" of my blog there are 50 posts. For get last 10 posts I do: http://mywordpress.com/?json=get_category_posts&slug=news&count=10&status=publish And it work correctly. Now I want to get my posts from 11 to 20 skipping last 10 posts, etc. How can I do?

The post count defaults to whatever you set in the wordpress backend (settings -> reading). You can achieve pagination by just adding the page parameter. So if you want the posts 11-20 you just call

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

You can't use get_category_posts with offset.

You have to construct the query from the basic get_posts which has a lot of parameters, see here:

http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

and here (read Method: get_posts):

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'

Be aware that use offset 'breaks' pagination

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM