Sign in
Log inSign up

How to use different page templates with gatsby and Wordpress source

Deano's photo
Deano
·Oct 26, 2018

I am building a site using gatsby js and Wordpress. This probably applies to using react without gatsby too. I have so far got all pages using a page.js file and all posts using post.js file which are set in my gatsby node config file.

How would I go about using a different layout for different pages based on a chosen template? ie I have created some empty page templates in Wordpress so I can assign a page a certain template. So for each page returned by wp api I get for example

slug: “contact”, template: “template-contact-page.php”, etc...

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct