New WordPress post to LinkedIn, X and Facebook
Every time you publish a WordPress post, this webhook sends it to one n8n webhook, which fans it out to 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, add a Webhook node — method
POST, path of your choosing — and copy its production URL. - Wire a LinkedIn, an X and a Facebook Pages node after it, connecting each account inside n8n.
- Protect the node with header auth, and store that token in the Credentials Vault. The import asks you for it; it is never part of a shared build.
What gets sent
{
"title": "Hello world",
"summary": "A short excerpt.",
"url": "https://example.com/hello-world/",
"image_url": "https://example.com/wp-content/uploads/2026/08/hero.jpg"
}publish_post hands over the post ID and the WP_Post object, so title and summary map straight across. The permalink and the featured image are not in that payload, so a pre-dispatch Code Glue snippet resolves them with get_permalink() and get_the_post_thumbnail_url(), falling back to get_the_excerpt() when the excerpt is empty. Nothing else travels — unmapped fields are dropped, so the rest of the post object stays in WordPress.
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 a Code Glue snippet shapes the payload first and 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
/ Code Glue
before sending — Social Media Payload Enrichment (Permalink & Featured Image)
$postId = $payload['post_id'] ?? null; if ($postId) { $payload['url'] = get_permalink($postId) ?: ''; $imageUrl = get_the_post_thumbnail_url($postId, 'full'); $payload['image_url'] = $imageUrl ?: ''; if (empty($payload['summary'])) { $payload['summary'] = get_the_excerpt($postId) ?: ''; } } unset($payload['post_id']); return $payload;
Read any snippet before you import it — Code Glue runs PHP on your site.
/ Authentication
This build authenticates with a credential you supply on import. The shared file carries the name and type only — never the secret.
- n8n automation — bearer
/ 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