获取所有相关帖子,除了使用ReactJ中使用wpgraphql的当前帖子以外

发布于 2025-02-11 06:23:59 字数 393 浏览 1 评论 0原文

我正在尝试抓住相关的帖子,除非使用 wpgraphql 当前文章。我的想法是排除当前帖子的 id ,并在该类别中显示所有相关的博客文章。

我是 GraphQl 的新手,我不知道该如何解决它。这在GraphQL中可以吗?请帮忙

query MyQuery {
  category(idType: DATABASE_ID, id: 1) {
    posts {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

I'm trying to grab the related posts except the current post using WPGraphQL. My thought is to exclude the ID of the current post and display all related blog posts within the category.

I'm new to GraphQL, I don't know how to figure out to solve it. is this possible in GraphQL? Please help

query MyQuery {
  category(idType: DATABASE_ID, id: 1) {
    posts {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红焚 2025-02-18 06:23:59

posts 类别下的连接字段上使用where.notin参数。

query MyQuery($currentPostId: ID) {
  category(idType: DATABASE_ID, id: 1) {
    posts(where: {notIn: [$id]}) {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}

Use the where.notIn argument on the posts connection field under category, like so.

query MyQuery($currentPostId: ID) {
  category(idType: DATABASE_ID, id: 1) {
    posts(where: {notIn: [$id]}) {
      edges {
        node {
          id
          title
        }
      }
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文