1. 13
    Add a Custom Post Type to the GraphQL Headless WordPress API Endpoint
    1m 40s

Add a Custom Post Type to the GraphQL Headless WordPress API Endpoint

Share this video with your friends

Send Tweet

In this lesson, we will expose a Custom Post Type to the graphQL layer. This would normally be done in the Custom Post Type Plugin UI but if you browse the options you'll notice that there is no setting for GraphQL. This means we will need to write a custom function that exposes our user-created post type.

We will use add_filter in our headless.php file to expose the chairs post type. The filter we'll use is register_post_type_args. There are three fields that need to explicitly declared: show_in_graphql, graphql_single_name, graphql_plural_name.