WordPress的盖茨比

时间:2020-06-26 06:41:51

标签: php wordpress graphql gatsby

我将Gatsby与Wordpress结合使用。我根据文档进行了所有设置。

但是当我转到Graphql查询浏览器(可以在其中生成graphql查询)时,没有与Wordpress相关的查询。错误是:

无法查询Query类型的allWordpressPost字段。

我还安装了“ gatsby-source-wordpress”模块。

这是我的global.config.js代码:

module.exports = {  siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,  },
plugins: [
`gatsby-plugin-react-helmet`,
{
    resolve: `gatsby-source-wordpress`,
    options: {
        // Specify the URL of the WordPress source
        baseUrl: `example.com`,
        protocol: `https`,
        // Indicates if a site is hosted on WordPress.com
        hostingWPCOM: false,
        // Specify which URL structures to fetch
        includedRoutes: [
          '**/posts',
          '**/tags',
          '**/categories'
        ]
    }
},
{
  resolve: `gatsby-source-filesystem`,
  options: {
    name: `images`,
    path: `${__dirname}/src/images`,
  },
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
  resolve: `gatsby-plugin-manifest`,
  options: {
    name: `gatsby-starter-default`,
    short_name: `starter`,
    start_url: `/`,
    background_color: `#663399`,
    theme_color: `#663399`,
    display: `minimal-ui`,
    icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
  },
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,

], }

有帮助吗?

1 个答案:

答案 0 :(得分:0)

您是否已安装并启用了必要的Wordpress插件以启用graphql(WPGraphQL,WPGatsby)?请查看official documentation步骤。对我来说很好。

考虑使用此starter而不是自己进行设置。