New WordPress post to LinkedIn, X and Facebook
Simplified after publishing. This build now sends only
post_id, so it matches the n8n template exactly. The AI transcript below shows the original build, which also mapped the title and excerpt and used a Code Glue snippet to add the permalink and featured image. The template now fetches all of that itself.
Every time you publish a WordPress post, this webhook sends its ID to one n8n webhook. The n8n workflow reads the post from your site's REST API and shares it on LinkedIn, X (Twitter) and Facebook: three networks from one delivery, no per-network plugin and no Zapier task cost.
Why it goes through n8n
None of the three social APIs accept a plain API-key POST — LinkedIn, X and Facebook all require OAuth on your app's behalf, and an OAuth dance is not something a webhook can perform. n8n holds those connections, so WordPress only ever talks to one URL.
That URL is the only thing you maintain. Add Mastodon or Bluesky later and nothing changes in WordPress.
What you need first
- In n8n, import the template, Share new WordPress posts on LinkedIn, X and Facebook via webhook, and set your site's address in its Settings node.
- Connect your LinkedIn, X and Facebook accounts inside n8n. The template's notes link each network's API access page; note that X is pay-per-use.
- Open the New Post Webhook node, add a Header Auth credential with the name
X-Webhook-Tokenand a long random token as the value, and copy the node's production URL. - Import this build. The webhook arrives disabled: replace its endpoint URL with that production URL, give the import the same token when it asks for the credential, then enable it. The token lives in the Credentials Vault and is never part of a shared build.
What gets sent
{
"post_id": 123
}publish_post hands over the post ID and the WP_Post object; args.1.ID is mapped to post_id and nothing else travels, because unmapped fields are dropped. The template fetches the title, excerpt, permalink and featured image from /wp-json/wp/v2/posts/{post_id}, which WordPress serves publicly for published posts. If a security plugin blocks anonymous REST access, switch the template's Get Post node to an application-password credential.
It only fires on a real publish
publish_post is not a "new post" hook. WordPress fires it on every save where the status is publish, so editing a live article would announce it a second time. A condition on the old status — args.2 must not equal publish — keeps this to genuine first publications.
If a delivery fails
Delivery is asynchronous, so publishing a post never waits on n8n. A failed POST is retried 5 times — 1m, 2m, 4m, 8m — and every attempt is kept in the delivery log with the full request and response. If n8n was down for the whole ladder, hit Replay once it's back and the post goes out without republishing it.
A
200from the webhook node only means n8n accepted the payload. Check n8n's own execution list to confirm all three social nodes succeeded.
/ The conversation
This build was not assembled by hand. Its author described what they wanted in Build with AI, and the agent read the site, planned the work and applied it. This is that conversation.
When new post is published lets fan out LinkedIn, X and Facebook posts. This will be done via n8n https://n8n.flowsystems.pl/webhook/30f81536-58e9-4e1d-95ab-38c63e948215 We need to send title, url, excerpt named as summary and featured image url as image_url
Checking the captured payload for post publishing to map title, URL, excerpt, and featured image correctly...
I will set up an integration to trigger your n8n workflow whenever a WordPress post is published. Here is the plan:
- Create Webhook: Disabled webhook pointing to your n8n URL for
publish_postevents. - Field Mapping: Map
args.1.IDtopost_id,post_titletotitle, andpost_excerpttosummary. - Code Glue Snippet: Use a pre-dispatch PHP snippet to resolve
url(permalink) andimage_url(featured image) using standard WordPress functions, with a fallback forsummaryif empty. - Preview & Assign: Test the snippet against captured payload and attach it to the webhook.
- Test Dispatch: Send a live test delivery to verify n8n accepts the payload.
- Enable Webhook: Turn on the integration so future published posts automatically dispatch.
Step step_6 (test_dispatch) did not succeed: The endpoint rejected the test delivery with 403 — it needs authentication. Attach a credential to the webhook, then retry. The endpoint responded: Authorization data is wrong! Fix the build so this passes — adjust the field mapping or the pre-dispatch Code Glue snippet as needed — then test again before enabling.
Checking stored credentials to see if an auth header or token for n8n is already available...
The test dispatch was rejected by n8n with HTTP 403. I will attach your stored n8n automation credential (#11) to Webhook #31, send another test dispatch, and enable the webhook once verified.
Published by the author on purpose. Tool output and raw payloads never travel with a shared build, and secrets never leave the site they were created on.
/ Abilities used (9)
- create_webhook Create disabled webhook for publish_post pointing to n8n
- set_mapping Map post ID, title, and excerpt for n8n payload
- create_snippet Create PHP snippet to inject URL, featured image URL, and summary
- preview_snippet Preview the payload transformation with the Code Glue snippet
- assign_snippet Attach the pre-dispatch snippet to the webhook
- test_dispatch Send test delivery to n8n webhook failed
- assign_credential Attach stored n8n credential (#11) to Webhook #31
- test_dispatch Retry test delivery with authentication header
- enable_webhook Enable Webhook #31 to go live
Each of these is a real ability the agent can call — see the docs for what each one does.
/ What runs
Every attempt is retried on its own schedule and written to the delivery log.
WordPress fires the action publish_post, if the conditions below match, the payload is mapped and sent as POST to n8n.flowsystems.pl.
The delivery is queued and sent in the background, so the visitor never waits. Along the way authentication comes from a credential you supply on import.
/ How it is configured
/ Only when
- args.2 does not equal publish
- ↳ otherwise the delivery is skipped, and logged as skipped
/ Field mapping
/ Authentication
This build authenticates with a credential you supply on import. The shared file carries the name and type only — never the secret.
- n8n webhook token — api_key
/ Use this build
Download the file, then in WordPress open Webhook Actions → Webhooks → Import and drop it in. Anything needing authentication asks you to pick or create a credential as it imports — see Import & Export for what travels with a build and what does not.
/ Questions