0

How do I override the search template i.e. used inside a theme with a custom search page inside a plugin? Please point our any relevant action/filter hooks which can be used to do this.

Any help is highly appreciated.

2

You can use template_include filter hook

add_filter('template_include','my_custom_search_template');

function my_custom_search_template($template){
    global $wp_query;
    if (!$wp_query->is_search)
        return $template

    return dirname( __FILE__ ) . '/my_search_template.php';

}
0

If i read your question correctly then it has been answered on stackoverflow. The link covers creating custom page templates upon plugin activation and also covers template redirect hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.