WordPress   

Load custom search template from plugin

Code snippet to load custom search template from a WordPress plugin.

add_filter('template_include','load_custom_search_template');

function load_custom_search_template($template){
    global $post;
    if (is_search()){
        $template = plugin_dir_path( __FILE__ ) . "templates/custom-search.php";
    }
    return $template;
}
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us