More than one search results page template

On my current project, I have to create 2, distinct templates to receive 2 distinct search results of the same site.

Both researches are coming from different forms on different templates/pages.

Read More

Thing is, there is only one search.php file in WordPress, and I don’t think it’s possible to create another one. (like search-taxonomy.php)

Is there a way to separate one search result of the other, and to then display the correct search page template in relation to which search form has been filled?

Related posts

Leave a Reply

2 comments

  1. You could make a page template http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    And then you could post some data via $_GET /search2/?search=xxx to that page and do a custom wp_query where you use ‘s=’ . $_GET[‘search’]
    http://codex.wordpress.org/Class_Reference/WP_Query

    Something like this:

    $args = array(
       's' => $_GET['search']
    );
    $the_query = new WP_Query( $args );
    
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;