Displaying Single Post of the Custom Post Type
Learn to create a page for displaying a single post of the custom post type.
We'll cover the following...
When we visit a course post, we can see that the page is being powered by single.php
. It displays a link Back to Blogs as well as the post metadata of author, date, and category. We would want the page to look different because a course post is different from a blog post. We need to create a template file for the course posts.
For a custom post type, WordPress is automatically on the lookout for single-{post-type}.php
file. Recall this image from the Template Hierarchy lesson.
single-course.php
Inside the theme folder, create a file named single-course.php
. We will write a test message Hello from single-course.php in the file to make sure that it is being used to display the course posts. We should see the test message if we ...