【问题标题】:Wordpress GatsbyWordPress 盖茨比
【发布时间】:2020-10-16 17:41:53
【问题描述】:

我将 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`,
],
}

【问题讨论】:

    标签: php wordpress graphql gatsby


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-07
      • 2021-12-14
      • 2022-08-19
      • 2021-07-30
      • 2020-12-02
      • 2021-07-12
      • 2019-04-02
      • 2021-08-22
      相关资源
      最近更新 更多