Search⌘ K
AI Features

Displaying Single Post of the Custom Post Type

Explore how to display single posts of custom post types in WordPress by creating dedicated template files like single-course.php and single-teacher.php. Learn to customize breadcrumb navigation, modify content display, and ensure proper permalink settings to enhance user experience on your custom post types.

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