-
Notifications
You must be signed in to change notification settings - Fork 654
-
Notifications
You must be signed in to change notification settings - Fork 654
Include next/previous links in single post responses #783
Comments
Interesting request. I'm not 100% on the best way to accommodate off the top of my head, but we'll keep it in the backlog of potential enhancements. |
Including |
Thanks. I'll take a look at the |
+1 for the idea of adding "prev" and "next" objects to |
I know that using json_prepare_post for this should be trivial, but I'm having a heck of a time getting it to go. It's as if the filter is using $post rather than the actual post being prepared, so it only returns the previous link of the most recent post.
|
The problem is that One way of solving this is by temporarily overriding the global post.
|
I knew getting around the global post was how to do it, just couldn't figure out how ... you are a scholar and a gentleman, many thanks for your help! This is just a temporary workaround until the 2.0 milestone but since I'm not sure how long that'll be, this is a huge help for now. |
well, i don't know how to using 'load more' or lazy load posts for my mobile app using this api, because example using page=2 query var in /wp-json/posts will return exist post if my blog update post like every 5 minutes. maybe any hint ? |
If I understand you right and you're saying you add so many posts so quickly that page 1 would quickly become page 2, I think that would be a problem whether you were using the API or not ;) (If you add your post IDs to a do_not_duplicate array, you can work that out, though.) Setting that aside for the moment, the API is perfect for doing lazy load of pages.
Spend some time with https://github.com/scottopolis/wp-rest-api-demo/blob/master/js/app.js which is for an app, but it's pretty simple and outlines one method of doing this ... |
+1. @rachelbaker: will this also work for a request that uses the format: |
Would |
We aren't going to add this to the Posts controller for the foreseeable future (discussion): rmccue [3:22 PM] We can do it naively, which is our best option |
I found this issue via search engine and wanted to point to a Stack Overflow answer, where I provided a naive, but simple filter function for this feature – just in case somebody needs it for a project: |
This is a feature request.
It would be good when using the
/posts/:id
endpoint if the next and previous post IDs where returned with the JSON data. It would make it easier to implement a 'next/previous' button in an app without making any extra calls.The text was updated successfully, but these errors were encountered: