-4

I am wanting to build a single page portfolio that is structured in sections like: intro projects CV contact

I have a separate page for each of those sections created in wordpress. How can I render each wordpress page to one single page with gatsby?

Here is where im creating gatsby pages from wordpress API: https://github.com/joeymorello/port-site/blob/master/gatsby-node.js

whoMe
  • 227
  • 2
  • 13
  • Add a similar query (to the one that is in your `gatsby-node.js`) to your index page component. Loop through each node of `allWordpressPage`, and display them somehow. – ksav Sep 23 '19 at 07:44

2 Answers2

1

If you want the contents of one page to be embedded into another page without having to copy the entire content you would need to use shortcodes. You can try a plugin for that such as this one: https://wordpress.org/plugins/insert-pages/

MistaPrime
  • 1,591
  • 1
  • 10
  • 20
0

A very simple example might be adding something something like this to your pages/index.js :

import React from "react"
import { graphql } from "gatsby"

const IndexPage = ({ data }) => {
  const { allWordpressPage } = data
  return (
  <>
    {allWordpressPage.edges.node.map(node => {
      const { title, content, id } = node
      return (
        <section key={ id }>
          <h2>{{ title }}</h2>
          <div>{{ content }}</div>
        </section>
      )
    })}
  </>
}
)}

export default IndexPage



export const pageQuery = graphql`
  query {
    allWordpressPage {
      edges {
        node {
          id
          title
          content
        }
      }
    }
  }
`
ksav
  • 20,015
  • 6
  • 46
  • 66