Gatsby: [gatsby-source-wordpress] Custom Post Types does not appear in GraphiQL

Created on 12 Dec 2018  路  2Comments  路  Source: gatsbyjs/gatsby

Description

The gatsby-source-wordpress plugin does not fetch my custom post types from CPT UI plugin, but it does fetch the taxonomies, so I suspect this might be a bug.

Proof that the post type is showing on the WordPress REST API:
https://portfoliostage.kodefant.space/wp-json/wp/v2/portfolio

Node v10.12.0
Gatsby v2.0.53
WordPress v4.9.8

Steps to reproduce

Cloning this repo and trying to find the portfolio post type in the GraphiQL explorer should expose the problem.
https://github.com/kodeFant/gatsby-wordpress-cpt-bug

It fetches data from this WordPress Page
https://portfoliostage.kodefant.space

Expected result

I believe that a new entry for the Post Type should appear, as the documentation states that Custom Post Types works out of the box.

Actual result

The post type does not appear, but the custom post types taxonomy "tech" appears just fine in GraphiQL.
https://portfoliostage.kodefant.space/wp-json/wp/v2/tech

I believe the Custom Post Types UI Settings should be correct:
screenshot from 2018-12-12 21-34-40

Most helpful comment

hey mate. i took a quick look at your gatsby-config.js and the problem is pretty simple. you have to whitelist the corresponding routes for your cpt like this

includedRoutes: [
          "/*/*/posts",
          "/*/*/pages",
          "/*/*/media",
          "/*/*/menus"
          "/*/*/portfolio"
        ]

this should solve it.

All 2 comments

hey mate. i took a quick look at your gatsby-config.js and the problem is pretty simple. you have to whitelist the corresponding routes for your cpt like this

includedRoutes: [
          "/*/*/posts",
          "/*/*/pages",
          "/*/*/media",
          "/*/*/menus"
          "/*/*/portfolio"
        ]

this should solve it.

Oh! It worked! Thank you so very much @arturhenryy!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

dustinhorton picture dustinhorton  路  3Comments

andykais picture andykais  路  3Comments

signalwerk picture signalwerk  路  3Comments