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.

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.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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;
share|improve this answer
    
@ Rob Vermeer Thank you very much, even I made many changes but it gives me a great start to fix my problem –  usama sulaiman Feb 2 at 19:15
    
I face only a problem, my working pagination not working any more in that search page, I start my search page like below (I changed s with n to not stuck with normal search) if(!empty($_GET['n'])){ $args = array( 's' => $_GET['n'] ); $the_query = new WP_Query( $args ); and between the end of while and end of my if I added the pagination foodonia_pagination(); here is my_page –  usama sulaiman Feb 3 at 6:54
add comment

As far as I know it's not possible to run two separate searches using WP. What you could do is categorize them under separate headers in your results. It is possible to limit searches to a specific category.

Take a look and see if this plugin helps you at all: http://wordpress.org/extend/plugins/search-everything/

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.