I've created a plugin from which I want to load the template for my custom post type. I've used this guide to load the template from plugin Click Here!

The templates are loaded perfectly in the page post type even though I've already specified the custom post type name in the page template header.

Template Post Type: custom-post-type

I can create a template in the theme folder and it perfectly works with custom post type.

1 Answer 1


The templates in your plugin don't show up in your CPT because the templates are loaded from your theme (or child theme).

You'll need to either

  1. Place the template in the root theme / child theme folder or
  2. Create a placeholder template file that "calls" the original

In the second case (which I've had to do a few times), I use something like this for the template in the theme / child theme:

 Template Name: My Custom Template

include WP_PLUGIN_DIR.'/my-plugin/templates/my-template.php';

...while I'm sure there's a better way at it; this works quite well. If you want to get really fancy, you could also add something to the plugin's activation hook that copies this into the current theme.

  • But template from plugin works perfectly in default page type!
    – Arman Khan
    Nov 13, 2019 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.