WordPress Gatsby get parent props

WordPress Gatsby get parent props


0

I’m a grapql newby and struggling to get the parent props from current page.
In gatsby-node.js I create all wordpress pages with:

createPage({
          path: `${page.node.uri}`,
          component: PageTemplate,
          context: {
            id: page.node.id,
            title: page.node.title,
            parentId: page.node.parentId
          },
        })

Then on the page I use following to get data from current page with:

query($id: String!) {
    wpPage(id: {eq: $id}) {
      id
      title
      uri
      content
      parentId
    }
  }

What I need is getting the parent props IF the page has a parentId, any suggestions?
Thanks in advance!


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *