'Error while adding page template from custom plugin wordpress

add_filter( 'theme_page_templates', 'sf_add_page_template_to_dropdown' );

function sf_add_page_template_to_dropdown( $templates ){
   $templates[PLUGIN_URL.'templates/quiz-template.php'] = __( 'Page Template From Plugin', 'text-domain' );

   return $templates;
}




add_filter( 'template_include', 'pt_change_page_template', 99 );

function pt_change_page_template($template){
    if (is_page()) {
        $meta = get_post_meta(get_the_ID());
     
        $template = $meta['_wp_page_template'][0];

    }

    return $template;
}

I'm using this code in plugin file to add a custom page template from my plugin. Template is showing in ( Page Attributes -> Template ) but the error coming on frontend is ->

Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\wordpress2\wp-includes\template-loader.php on line 106

Warning: include(http://localhost/wordpress2/wp-content/plugins/mockTest/templates/quiz-template.php): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\wordpress2\wp-includes\template-loader.php on line 106

Warning: include(): Failed opening 'http://localhost/wordpress2/wp-content/plugins/mockTest/templates/quiz-template.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\wordpress2\wp-includes\template-loader.php on line 106



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source