Skip to content

WordPress Setup

Ben Marshall edited this page Feb 6, 2023 · 17 revisions

Turning WordPress into a Headless CMS isn't straightforward, so grab a cup of ☕️ because following these steps will take ~20 minutes.

The following instructions assume you'll be standing up a fresh local install of WordPress.

Requirements

Make sure you have the following dependencies:

WordPress Setup

Step 1: Install Plugins & Theme

  1. In your terminal, change directories to your new WordPress install's /wp-content directory, then download our composer.json.
curl -O https://raw.githubusercontent.com/Highfivery/nextjs-starter/main/backend/wordpress/composer.json
  1. Install the plugins in the WP Dashboard or use WP CLI:
composer install
  1. Activate all plugins & theme:
wp plugin activate --all
wp theme activate wordpress-headless

Step 2: wp-config.php

The following constants need to be in wp-config.php:

define( 'NEXT_PUBLIC_WORDPRESS_API_URL', 'http://localhost:3000/' );
define( 'GRAPHQL_JWT_AUTH_SECRET_KEY', 'your-key' );

Step 3: .env.local

In your Next.js Starter directory, create a .env.local with the following, replacing with your URL instance:

NEXT_PUBLIC_WORDPRESS_API_URL=https://wordpress-url.local

Step 4: Ant Design Gutenberg — Optional