Return scheduled posts with WP REST API
-
03-10-2020 - |
문제
I'm using WP REST API plugin for a custom web application and I need to get access to the scheduled posts of the target wordpress website. However I can't find any parameter or filter to achieve this on the documentation.
Have tried passing the future date of a post in the API request query string but nothing returns.
Tried to get a future (scheduled) post by passing directly his id with /wp-json/posts/57117
and I get an error response.
[{"code":"json_user_cannot_read","message":"Sorry, you cannot read this post."}]
How is the right way to access the data for scheduled posts? They are not password protected, just scheduled. This needs authentication somehow?
해결책
I found the answer, dropping it here in case someone need it.
You need to be logged in as a user that has the
edit_posts
capability. With that capability, you also get access to the private query vars, includingpost_status
.
Taken from this similar issue.