Retrieving WordPress Menus using GraphQL

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

const primaryMenu = ({ data }) => <pre>{JSON.stringify(data, null, 4)}</pre>

export const query = graphql`
  {
    menu(id: "PRIMARY", idType: NAME) {
      menuItems {
        nodes {
          key: id
          parentId
          title: label
          url
          description
          cssClasses
        }
      }
    }
  }
`

export default primaryMenu

Leave a comment

Your email address will not be published.