template_include for search.php makes WordPress think its on the home page
Your problem is that you are not resetting all the needed query variables, like WP_Query::$is_page, WP_Query::$is_single and WP_Query::$is_archive. Also note that ‘pre_get_posts’ is fired for all queries, the main and the secondaries, so you should check that you are working on the main query. Finally, when you get data from $_GETyou should sanitize it before … Read more