Posting on Social Media Accounts When There's a New Post to WordPress Site

What would the easiest way to trigger a workflow when there’s a new post on a WordPress site?

I’ve never done this, but there are a couple of things that I’d think about when using WordPress with n8n.io in this way. YMMV.

  • WP Webhooks: This enables you to create a webhook in WordPress for many post and user related actions. Use the Respond to WebHook node.
  • WordPress REST API: This enables you to use the HTTP Request node along with the Schedule Trigger node to poll a WordPress REST API endpoint and continue the workflow if there’s a new post. You’ll need to write some logic to find out if the latest post already existed at the last time that you did the HTTP request. There are also date and modified attributes on the posts endpoint that might be helpful here instead of say storing the latest post ID in a file/variable.

The webhook method is obviously more efficient, but this completely depends on you.

1 Like

Ok, I’ll user REST but how shoud I set the schedule?

If you’re familiar with crontab expressions, use a custom cron expression. Crontab guru is on that article. It’ll generate one for you.

An update to this thread, there’s also a Cron trigger.

I was researching on this very subject, I tried to put this together.

I am a beginner,

Has anyone managed to make it work?

Hey @denverfix,

As a starting point you could try the example below, It would in theory get any wordpress posts that have been published in the last 30 minutes and send them to twitter and telegram.

1 Like

Didn’t need to use webhook?

I wish I could do this for most social networks.

1 Like

If Wordpress has an option to post to a webhook when an article is published you could use that instead.

in your case you used WORDPRESS login and password in n8n?

Would you like to learn more about the N8N, any courses within the platform?

Hey @denverfix,

There is Courses - n8n Documentation for learning, Yeah so for the example you would add the credential in n8n and that will log in and do the magic. Sometimes with Wordpress sites though you don’t need valid credentials to read posts.

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