Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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';

}
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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