Custom Search Template for Custom Post Types
Try adding the return as well in the else{}, like this: function template_chooser($template) { global $wp_query; $post_type = get_query_var(‘post_type’); if( $wp_query->is_search && $post_type == ‘product’ ) { return locate_template(‘archive-products.php’); } else { $args = array_merge( $wp_query->query, array( ‘post_type’ => ‘post’ ) ); query_posts( $args ); return locate_template(‘archive-products.php’); } return $template; } add_filter(‘template_include’, ‘template_chooser’); Haven’t tested.