Wordpress 盖茨比

问题描述 投票:0回答:2

我正在使用 Gatsby 和 Wordpress。我根据文档设置了一切。

但是当我进入Graphql Query Explorer(可以生成graphql查询)时,没有与Wordpress相关的查询。错误是:

无法在查询类型上查询字段 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`,
],
}
php wordpress graphql gatsby
2个回答
0
投票

您是否安装并启用了必要的 Wordpress 插件来启用 graphql(WPGraphQL、WPGatsby)?一步步查看官方文档。对我来说效果很好。

考虑使用这个starter而不是自己设置。


0
投票

我假设您计划使用 Wordpress 作为 Gatsby 的无头 CMS?如果是这样,您可能会发现本教程很有用。它展示了如何使用 Docker 容器中的本地 Wordpress 实例进行设置。这使得调试您的设置变得更加容易。一旦你让这个工作正常,你就可以连接到你的实际 Wordpress 实例。

© www.soinside.com 2019 - 2024. All rights reserved.