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 required plugins

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

Install these plugins:

  1. WPGraphQL (by Jason Bahl)
  2. Search for "WPGraphQL" and click Install Now
  3. Activate the plugin
  4. Your GraphQL endpoint is now available at https://yoursite.com/graphql

  5. Pods (by Pods Framework Team) — for custom fields and custom post types

  6. Search for "Pods" and install
  7. Activate it
  8. Pods handles both custom fields and custom post types in one plugin (no need for a separate CPT UI plugin)
  9. Pods is 100% open source (GPL) and free

  10. WPGraphQL for Pods — to expose Pods fields to the GraphQL API

  11. Install and activate
  12. This makes your Pods fields available in GraphQL queries

Creating custom fields with Pods

Once Pods is installed:

  1. Go to Pods AdminEdit Pods in the WordPress admin
  2. Select an existing pod (e.g., Post) or create a new one
  3. Click Add Field
  4. Set the field name (e.g., featured_color) and choose a type (Plain Text, File / Image, Paragraph, etc.)
  5. In the field settings, make sure Show in GraphQL is enabled
  6. Click Save Pod

Pods fields now appear in your GraphQL API under each post.

Common field types: - Plain Text — short text (title, name, single line) - Paragraph — longer text (description, bio) - File / Image — a single image (featured image, thumbnail) - File / Image (multiple) — multiple images - Relationship — link to other posts - Pick (Select) — dropdown menu - Yes/No — checkbox/boolean - Date / Time — calendar field for dates

Creating custom post types

If your content doesn't fit WordPress's default "Post" and "Page" types, create a custom post type with Pods:

  1. Go to Pods AdminAdd New
  2. Select Custom Post Type
  3. Enter the post type name (e.g., team_member)
  4. Set the label (what appears in the admin, e.g., "Team Members")
  5. Make sure Show in GraphQL is checked in the pod settings
  6. Click Save Pod

The new post type now appears in WordPress and in GraphQL. You can add custom fields to it directly in the same pod definition.

Verifying the GraphQL endpoint

  1. Open your browser and go to https://yoursite.com/graphql
  2. You should see a GraphQL editor
  3. In the left panel, click the Schema icon (looks like a magnifying glass)
  4. Look for types like Post, Page, or your custom post types (e.g., TeamMember)
  5. Click on a type to see its available fields

If you see your content types, the API is working.

Testing the API with a simple query

In the GraphQL editor:

query {
  posts(first: 5) {
    edges {
      node {
        id
        title
        excerpt
      }
    }
  }
}

Click the play button. You should get back a list of your 5 most recent posts with their titles and excerpts. This proves the API is returning real content.

If you created Pods fields, they'll appear in the schema once WPGraphQL for Pods is enabled. Query them directly:

query {
  posts(first: 5) {
    edges {
      node {
        title
        featuredColor
        featuredImage {
          sourceUrl
        }
      }
    }
  }
}

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

  • "GraphQL endpoint not found" — Make sure WPGraphQL plugin is installed and activated.
  • Custom fields don't appear in GraphQL — Install "WPGraphQL for Pods" and check that "Show in GraphQL" is enabled on each field in the pod settings (Pods AdminEdit Pods → select the pod → check each field).
  • Custom post types don't appear — Go to Pods AdminEdit Pods, select the pod, and make sure "Show in GraphQL" is checked.
  • Query returns empty results — Check WordPress permissions. Private posts only appear to logged-in users.

Using ACF instead

If you prefer ACF (Advanced Custom Fields) over Pods, the workflow is similar. Install ACF + WPGraphQL for ACF instead of Pods + WPGraphQL for Pods. Note that ACF Pro is a commercial plugin (~$99/year), while Pods is fully free and open source.

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: You want to add a "Featured Image" field to your blog posts. Which plugin do you use?

  • A) Custom Post Type UI
  • B) Pods
  • C) WPGraphQL
Answer

B) Pods — Pods lets you define custom fields for posts and other content types. Go to Pods AdminEdit Pods, select your pod, and add fields without coding.

Q3: You created a custom post type called "Portfolio Item" but it doesn't appear in GraphQL. What's the most likely issue?

  • A) WPGraphQL isn't installed
  • B) "Show in GraphQL" is not enabled on the custom post type
  • C) You need to create custom fields for it first
Answer

B) "Show in GraphQL" is not enabled on the custom post type — When creating a custom post type with Pods, you must check the "Show in GraphQL" setting in the pod configuration for it to appear in your API.

Q4: You added a Pods field called featured_color to your posts. What plugin do you need to query it from GraphQL?

  • A) WPGraphQL for Pods
  • B) Custom Post Type UI
  • C) Just Pods and WPGraphQL
Answer

A) WPGraphQL for Pods — This bridge plugin exposes Pods fields to the GraphQL API. Without it, Pods fields may not appear in GraphQL queries.

Edit this page on GitLab