Closed NeaMitika closed 3 years ago
After a lot of GUGLING i have found a solution... this one is not perfect... but is a start
Ofc you have to make a template file like Wordpress is asking... i have saved mine here (templates/single-pianta.php) inside plugin's folder
public function template_custom_post_type( $template ) {
global $post;
if (is_singular( 'pianta' ) ) {
$template = plugin_dir_path(__DIR__).'templates/single-pianta.php';
}
elseif (is_archive( 'pianta' ) ){
$template = plugin_dir_path( __DIR__ ).'templates/archive-pianta.php';
}
return $template;
}
$this->loader->add_filter( 'template_include', $plugin_admin, 'template_post_type_template' ) ;
I was wondering, is there any way to create a page/post template from inside the plugin? I know its possibile to create it from inside a wordpress theme folder, but i cant find any working code online to create it from a plugin.. Maby this could be a feature for a next boilerplate update?