You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add this PHP snippet to your theme’s `functions.php` or a custom plugin to create a webhook that triggers on post updates and calls your Next.js revalidation API:
36
+
### Creating a Webhook via the Admin UI
37
+
You can easily create and manage webhooks directly from the WordPress admin dashboard, without writing any code. The intuitive Webhooks UI allows you to specify the event, target URL, HTTP method, and custom headers for each webhook. This makes it simple to connect WordPress events to external services and automate your workflows.
## Testing the Integration with the Example Project
94
+
95
+
To verify that your webhook integration is working correctly, follow these steps:
96
+
97
+
1. Run the example project in production mode. (see ## Command Reference section)
98
+
99
+
2. In WordPress, update or create a new post, for example with the slug `/posts/new-post`.
98
100
101
+
3. Visit the corresponding page on your headless site at:
102
+
103
+
`http://localhost:3000/posts/new-post`
104
+
105
+
106
+
Refresh the page to see the updated content served via Incremental Static Regeneration (ISR).
107
+
108
+
4. Check the Next.js server logs. You should see logs indicating that the webhook revalidation request was received and processed successfully, similar to the following:
109
+
110
+
```bash
111
+
[Webhook] Received revalidation request
112
+
[Webhook] Secret from header: Provided
113
+
[Webhook] Expected secret is set: Yes
114
+
[Webhook] Secret token validated successfully
115
+
[Webhook] Request body parsed: {
116
+
key: 'cG9zdDoyNDI=',
117
+
path: '/posts/new-post/',
118
+
graphql_endpoint: 'mysite.local/graphql',
119
+
smart_cache_keys: [ 'cG9zdDoyNDI=' ],
120
+
_webhook_meta: {
121
+
sent_at: '2025-06-24 12:19:15',
122
+
webhook_id: 254,
123
+
webhook_name: 'Test Post Published Webhook',
124
+
event_type: 'post_updated'
125
+
}
126
+
}
127
+
[Webhook] Path to revalidate: /posts/new-post/
128
+
```
129
+
130
+
This confirms that the webhook triggered by your WordPress post update is successfully revalidating the page on your headless Next.js site.
99
131
100
132
## How It Works
101
133
This integration:
@@ -143,7 +175,6 @@ Congratulations, WordPress should now be fully set up.
143
175
144
176
> **Note:** The login details for the admin is username "admin" and password "password"
0 commit comments