Regardless of the name of your custom post type, you can load a special template which only displays on one single post when using custom post types.
For non custom post types, you would simply include the slug or post i.d in the file name of the template according to the WordPress Template Hierarchy however this isn’t supported for CPT’s so you need to use the single_template filter.
Here’s 3 working examples which you can use in:
- A plugin – Loads the template from the plugins root directory with the file name plugin-cpt-template.php
- A child theme – Loads the template from the parent themes root directory with the file name parent-cpt-template.php
- A parent theme – Loads the template from the child themes root directory with the file name child-cpt-template.php
Leave a Reply