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...