function custom_template_from_plugin($path) { global $post; if( $post->post_type == 'custom_post_type' ) { $custom_post_type_template_file = plugin_dir_path( __DIR__ ) . 'inc/custom_post_type_template.php'; if ( file_exists( $custom_post_type_template_file ) ) { return $custom_post_type_template_file; } } return $path; } add_filter('single_template', 'custom_template_from_plugin');