Skip to content

WordPress setup

To use WordPress as your CMS with Silex, you need to expose your content via a GraphQL API. This page walks you through the plugins and setup required.

You need a WordPress site you can edit. If you're testing locally, use a local WordPress installation or a staging site. The plugins below are free and widely used.

Installing the required plugin

Log into your WordPress admin dashboard and go to Plugins > Add New.

Install WPGraphQL (by Jason Bahl):

  • Search for "WPGraphQL" and click Install Now
  • Activate the plugin
  • Go to GraphQL > Settings: the address of your GraphQL API is shown under the GraphQL Endpoint field. Copy it, you will paste it in Silex when you connect the data source

Adding custom fields with ACF (optional)

WordPress posts already have a title, content, excerpt, author, date and featured image. If your content needs more fields (a price, a color, a second image), you can use ACF (Advanced Custom Fields).

Install ACF and WPGraphQL for ACF. WPGraphQL for ACF makes your ACF fields visible to Silex.

Public vs. private content

By default, WPGraphQL respects WordPress permissions. If a post is set to "Private", it only appears in GraphQL if the user is logged in.

For a public site, make sure your content is published and set to public in WordPress. For authenticated access (e.g., a member-only site), you may need to add authentication headers when connecting from Silex.

Common issues

  • Silex cannot connect to your site: make sure the WPGraphQL plugin is installed and activated, and that you pasted the address shown in GraphQL > Settings.
  • Lists are empty in Silex: check WordPress permissions. Only published content appears. Private posts only appear to logged-in users.
  • Error "GraphQL introspection is not allowed for public requests by default": Silex needs to read your schema, and WPGraphQL blocks this for public requests. In the WordPress admin, go to GraphQL > Settings and check the public introspection option: Enable Public Introspection, or Let logged-out visitors read the schema (introspection) in recent versions. Save, then connect the data source again.

Triggering rebuilds from WordPress admin

Once your Silex site is live, you can let WordPress editors trigger a rebuild without opening Silex. This is useful for clients who only edit content in WordPress and don't need access to the editor.

Goal: when an editor clicks the Deploy Website button in the WordPress admin bar, GitLab rebuilds the static site with the latest content.

  1. Install the WP Jamstack Deployments plugin in WordPress, then go to Settings > Deployments.

  2. In your GitLab repo, create a pipeline trigger token: Settings > CI/CD, expand Pipeline trigger tokens, click Add new token, enter a description and click Create pipeline trigger token. Copy the Project ID, the branch name (e.g., main), and the trigger token.

  3. In Settings > Deployments, paste the GitLab pipeline trigger URL in the Build Hook URL field:

    https://gitlab.com/api/v4/projects/PROJECT_ID/ref/BRANCH/trigger/pipeline?token=TRIGGER_TOKEN
    

    Example:

    https://gitlab.com/api/v4/projects/75822331/ref/main/trigger/pipeline?token=glptt-xxxxxxxxxxxx
    
  4. Click the Deploy Website button in the WordPress admin bar. GitLab starts a pipeline and rebuilds the site. Check the Jobs view in GitLab to confirm.

The plugin can also display a deployment status badge in the WP admin header.

Learn more


Quiz

Q1: You installed WPGraphQL but your GraphQL endpoint isn't accessible. What's the first thing to check?

  • A) Restart your WordPress server
  • B) Make sure the WPGraphQL plugin is activated
  • C) Check that your domain has SSL (HTTPS)
Answer

B) Make sure the WPGraphQL plugin is activated — Just installing the plugin isn't enough; it must be activated. Go to Plugins and verify the status.

Q2: Your client's posts need an extra field, for example a price. What do you install?

  • A) ACF and WPGraphQL for ACF
  • B) Only ACF
  • C) Nothing, WPGraphQL shows every field
Answer

A) ACF and WPGraphQL for ACF: ACF creates the field in WordPress. WPGraphQL for ACF makes it visible to Silex.

Q3: Silex is connected to WordPress, but your lists are empty. What do you check first?

  • A) That the posts are published, and not private or drafts
  • B) That your domain has SSL (HTTPS)
  • C) That ACF is installed
Answer

A) That the posts are published, and not private or drafts: only published content appears. Private posts only appear to logged-in users.

Edit this page on GitLab