Open Jeremaya45 opened 6 years ago
You would need to define PLUGIN_PATH in the index.php file as a constant to use it that way.
This seems like a better way (if you're already using OOP in your plugin) to add page templates to your plugin: http://www.wpexplorer.com/wordpress-page-templates-plugin/
@slushman I added to the top level index.php the following lines
if ( !defined( 'PLUGIN_PATH' ) ) {
define( 'PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
but it still doesn't work
https://github.com/DevinVinson/WordPress-Plugin-Boilerplate/issues/552
check this out i made this for my CPT template maby it can help you
Hello,
I tried to implement a functionality of adding custom template to wordpress. This is the function I added to file class-myplugin-public.php
The template file itself is located at public/partials/bn-single-post.php
I also added to define_public_hooks function the following filter
$this->loader->add_filter( 'single_template', $plugin_public, 'my_custom_template' );
However it does't work. It seems like PLUGIN_PATH is not defined. This is the source of where I grabbed the code: https://wordpress.stackexchange.com/questions/17385/custom-post-type-templates-from-plugin-folder