How to upload feature image to wordpress?

Hi community. Does anyone knows how to do that?

Thx

Hi @ManyQuestions, looks like @martinhache provided an example of how to upload an image to WordPress over here. It seems to me you can follow this up with the HTTP Request node sending a POST request to https://example.com/wp-json/wp/v2/posts/<id> with a featured_media body parameter sending the ID of the image you’ve just uploaded.

Let me know if you run into any error trying this.

1 Like

Hi again. Thx for the answer. I tried to understand what to do to realize it, but i can’t figure it out. Can u show a workflow?

Hi @ManyQuestions, check out the linked thread for an example workflow:

1 Like

Hi @MutedJam. I have seen this yesterday already and pasted it as i is in my workflow after the final node, where i publish to WordPress. It didn’t work.

Perhaps you can elaborate on what exactly isn’t working? What exactly are you sending, which error are you seeing?

1 Like

SCR-20230628-ncmg

This is the node, without credentials set:

and with cred, it doesn’t run through:

This looks like a screenshot from a previous execution and my best guess is that your workflow has stopped before even reaching the HTTP Request node. Can you share a screenshot of the full execution showing all nodes?

1 Like

Hi @MutedJam sadly, i can’t do that. It’s a big workflow with alot of sensitive information. Can somebody share an working example flow? I can properbly figure it out from there.

Hi buddy, I can’t think of a better example than @martinhache already shared on the other thread of yours to be honest. So without a reproducible example from your end and a better understanding of your current problem I think I’m stuck :frowning:

2 Likes

Hey guys,

I think the error is coming from the endpoint that the HTTP3 node in the image is pointing to.

To add the featured image to a WordPress post, a POST request must be made to the URL https://example.com/wp-json/wp/v2/posts/ID_POST_TO_UPDATE and not /wp-json/wp/v2/media/ as it appears in the screenshot.

What we are doing in this call is telling the WordPress API to update the post ID XXX with the image with post ID YYY as the featured image.

3 Likes

@MutedJam @martinhache Thanks guys. I figured it out and learned something along the way - optimal result so to say. :laughing:

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.