Wordpress node returns only published posts

Hey, I can’t get the WordPress node to return any posts that are not published yet. Is that a bug?

@bartv when you use this flow you don’t get all the posts?
Flow - Get all posts from WordPress - https://n8n.io/workflows/546

Can you please share your flow.

Good morning both :wave:

I quickly looked into this and could confirm the behaviour. It seems the Wordpress API only returns posts with a publish status (unless another other status is specified).

I’ll try adding an optional field for the status and see if that fixes the behaviour. I’ll be back!

2 Likes

Doing an authenticated call on /wp-json/wp/v2/posts?status=pending will return those posts - I’m using an HTTP node as a workaround for now.

PS: if you’re looking at the wordpress node anyway, the ‘filter by author’ option throws an error when you execute it.

1 Like

Yes, that is pretty what I am currently trying to implement. This should also solve your feature request:

Whoops sorry, I mixed that up yes :sweat:

Okay here we go:

Will let you know once it’s released.

2 Likes

Pew pew! Thanks :slight_smile:

Got released with [email protected]

1 Like

I tested the post type filter and it is only allowed to filter published posts other post types are not allowed.

400 - {"code":"rest_invalid_param","message":"Invalid parameter(s): status","data":{"status":400,"params":{"status":"O status is prohibited."},"details":{"status":{"code":"rest_forbidden_status","message":"Status is prohibited.","data":{"status":401}}} }} - Invalid parameter(s): status

NodeApiError: Bad request - please check your parameters
    at Object.wordpressApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Wordpress/GenericFunctions.js:28:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Wordpress/Wordpress.node.js:253:44)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:696:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:656:53

You can workaround it with a GET request to /wp-json/wp/v2/posts?status=[status], with status being of: publish , future , draft , pending , private