3
votes

Using the Wordpress REST API I am trying to get draft posts only. However the API responds with only the published posts when I pass the query in both cases.

A: http://localhost/wp-json/wp/v2/posts?status=draft

B: http://localhost/wp-json/wp/v2/posts?filter[post_status]=draft

How can I see only the draft posts? I am using the JWT Authentication for WP-API plugin for authentication but disabling this doesn't seem to change anything.

1
There isn't enough clarification on this but I do know it has to do with authentication permissions.ren.rocks
That's the answer I get: {"code":"rest_invalid_param","message":"Invalid parameter(s): status","data":{"status":400,"params":{"status":"Status is forbidden."}}} I think it's just not supported.Max Favilli
Hi @Wazzaday ! Any news on the matter ? Thank you...jDelforge
The correct solution is status=draft. But you need to make sure you are authenticated with a user that can see draft posts, otherwise the status field is just ignored.wazzaday

1 Answers

0
votes

This is because just installing the JWT Auth plugin doesn't solve the problem. There are also some modifications to be performed on the .htaccess file as well as in wp-config.php.

I hit a similar problem but with private posts, so I created a video detailing the steps you need to follow to install and configure the JWT Authentication plugin.

https://youtu.be/Mp7T7x1oxDk