A gatsby-source-wordpress demo
MIT License
The docs for: gatsby-source-wordpress
The above has an installation section which annoyingly doesn't tell you how to install gatsby-source-wordpress
,
instead it'll point you to a starter.
For reference here's the starter: gatsby-starter-wordpress-blog
yarn add gatsby-source-wordpress
You'll also need to install the peer dependencies
yarn gatsby-plugin-sharp gatsby-transformer-sharp
You can search official plugins and install WP GraphQL
and WP Gatsby
via WordPress. Ensure both are "activated" in
the "Manage Plugins" section of your WP site
The above docs don't show anything for gatsby-config.js
because it's all hidden away in the starter but...
// gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-wordpress`,
options: {
url: `https://xxx.com/graphql`,
},
},
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
],
}
Install Custom Post Type UI
by searching for it from the official plugins, then manually install
wpgraphql-for-custom-post-type-ui
by downloading it from GitHub as a zip
Install Advanced Custom Fields
by searching for it from the official plugins, then manually install
wp-graphql-acf by downloading it from GitHub as a zip
Create a Custom Post Type (CPT UI) and right at the bottom in the GraphQL settings make sure "Show in GraphQL" is set to true and it has the required "x x Name" settings
In Custom Fields set the location to the name of the Custom Post Type which should then surface the "fields" in the WP editor for that Customer Post Type
To ensure sure blocks styled using Gutenberg look the same in the Gatsby build as they do in the WordPress preview be sure to installed the below node modules.