Skip to main content

Claude/ChatGPT Prompt to Set Up Headless WordPress with a Next.js Frontend

Set up headless WordPress with a Next.js frontend via WPGraphQL/ACF, dynamic routes, and ISR with on-demand webhook revalidation.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt turns the model into a senior full-stack engineer and asks it to produce a complete headless WordPress + Next.js setup that returns real config and code rather than pseudocode. It anchors every deliverable to four placeholders: [wordpress_url] (the backend the frontend points at), [api_layer] (how content is exposed, e.g. WPGraphQL with ACF), [nextjs_version] (which router and version to scaffold against), and [content_types] (the ACF field groups and routes to model).

The structure works because it forces the awkward integration seams to be specified up front instead of discovered at launch. By naming [api_layer] and [nextjs_version] together, the output stays internally consistent — App Router data fetching differs from Pages Router, and a GraphQL layer needs different query code than REST. The explicit deliverable for ISR with on-demand revalidation (a WP save webhook hitting a revalidate route) targets the exact piece that usually fails silently: editors publish and nothing changes on the React frontend.

When to use it

  • You want clients to keep editing in familiar WordPress but need a fast React/Next.js frontend.
  • You are scaffolding a new headless project and want the ACF-to-frontend data flow defined before you write a line.
  • You keep hitting the "content updated but the live site never changes" problem and need the webhook-to-revalidate loop done right.
  • You need typed data fetching mapped to specific [content_types] rather than loose, untyped queries.
  • You are deciding between WPGraphQL and the REST API and want one consistent path picked for [api_layer].
  • You need preview mode for drafts and a sane fallback for not-yet-built dynamic routes.

Example output

Expect several labelled code blocks rather than prose: the WordPress side (ACF field group definitions and how they are exposed through [api_layer]), an example dynamic page using generateStaticParams, a typed fetch layer pointed at [wordpress_url], the on-demand revalidate route, and an ordered list of webhook setup steps. Image handling via next/image with WP media domains and SEO metadata mapped from WP fields round it out.

Pro tips

  • Set [content_types] precisely (e.g. posts, case studies, team members) — vague values produce generic ACF groups you will rewrite anyway.
  • Keep [api_layer] and [nextjs_version] matched to what you will actually ship; mixing routers or APIs in the answer creates code you have to reconcile.
  • Test the revalidate route end to end before launch — save a post in WP and confirm the change appears. A broken loop here makes the whole CMS feel dead.
  • Point [wordpress_url] at a staging backend first so a misconfigured webhook does not hammer production.
  • If preview mode misbehaves, ask the model to isolate just the draft-preview and fallback handling and explain the secret/token flow.

Frequently Asked Questions

Does this prompt use WPGraphQL or the REST API?
It uses whatever you put in the `[api_layer]` variable. The default suggests WPGraphQL with WPGraphQL for ACF, but you can set it to the WP REST API and the generated fetch layer and queries will follow that choice consistently.
Will it handle content updates showing up on the Next.js site?
Yes, that is the core of deliverable four. It builds ISR with an on-demand revalidate route triggered by a WordPress save webhook, which is the piece that most often fails silently and leaves the frontend stale.
Can I use the Pages Router instead of the App Router?
Set `[nextjs_version]` to a Pages Router version and the output adapts. The default targets the App Router with generateStaticParams, but the prompt keeps the data-fetching code consistent with whichever version and router you specify.
Does it cover draft previews and images?
Yes. The prompt explicitly asks for preview mode for drafts with a fallback for not-yet-built routes, plus image handling through next/image configured for your WordPress media domains and SEO metadata mapped from WP fields.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in WordPress & CMS Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support