My custom plugin creates a custom post type, and I want to theme my own "single-my_custom_cpt.php"
file. However, I want to store it in my plugin folder, and allow that it be over-written in the websites’ active theme folder.
For example, single-my_custom_cpt.php exists in /plugins/my-plugin/
folder, and someone creates /themes/site-theme/single-my_custom_cpt.php
. I want the theme file to come up first, and if it’s deleted, the plugin file to come up.
To provide a default template that can be overwritten by a theme hook into
template_include
like the linked questions suggest. You get the template WordPress wants to use as a parameter. If that is not the file you want â replace it with your pluginâs file: