I am building a mobile application that is pulling the json feed from a blog. I can easily query to get the latest 10 posts for example. But next, I want to be able to query the next 10. This presents me with a problem, because while pulling the first 10, another 2 posts may be added, so if I try to pull the next ten posts, I would get duplicates and get 8 unique posts instead of 10. I am trying to think of a way that I can simply get my last post id retireved, and request for the next ten posts after post id = x. I guess technically I would be getting the next 10 posts “before” that id, but I hope I explained my question.
Update:
I download recent posts
30 29 28 27 26 25 24 23 22 21
now I want to download next 10
20 19 18 17 16 15 14 13 12 11
Works perfect. But what happens if I want to download the next ten while x new posts were added. In this case we’ll use 3 as x
Download first 10
30 29 28 27 26 25 24 23 22 21
now the next 10
Whoops. Someone added 3 new posts
still try to get next 10
23 22 21 20 19 18 17 16 15 14
Got duplicates of 23 22 21.
I want to say get last post download aka(21) and take next ten after that
How would I make the api in the address bar to handle this?
Ha… While this makes a lot of sense, WP is not to good with arbitrary conditions like this and nothing like is implemented in
WP_Query
currently.However since your issue is really chronological rather than requiring dealing with IDs, you probably can make use of Date Parameters to restrict results to be older than time of oldest post you fetched instead of explicit offset by count.