WordPress separates “posts” from “pages”. In this video, we’ll learn how to extend page display code to create post pages and display their content.
Jason Lengstorf: [0:01] So far, we're pulling in our pages, but we also need to consider how we get our posts. To pull in posts, we can follow almost exactly the same process.
[0:10] We'll go in and we can just copy and paste this page-template and we're going to rename it to post-template. In here, we're going to get the post and then we'll swap out here to be post. We'll also rename this to postTemplate.
[0:34] Once we have this, we're ready to modify our gatsby-node. Inside of here, we can take our pages, duplicate that, switch it out to be posts. Then we're going to take this whole section and duplicate that and change it to be posts as well.
[0:54] In here, we want to use the post-template and the uri. For here, we want this to be prefix. We're going to prefix with blog/. Now that we've done this, we can stop and start our server.
[1:16] Once that build is successful, we can pull up the browser. Let's take a look at one of our posts. We can go to blog/WordPress-jamstack/ and we'll see that now our blog posts are loading.