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.

I have two different kinds of search results on my site and I'd like to change the look of the search result page entirely. I've played around with the search form a bit but I'm unsure how to force it to redirect to an alternate search.php Any help would be appreciated

<form role="search" method="get" id="searchsupport" action="/">
    <label class="screen-reader-text" for="s">Search for:</label>
    <input type="text" onfocus="if (this.value == 'Search')  
    {this.value = '';}" onblur="if (this.value == '')  
    {this.value = 'search';}" id="s" name="s" value="search" class="search-form round"> 
    <input type="hidden" id="searchsubmit"> 
    <input type='hidden' name='post_type' value='software, documents' />
</form>
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

you can add an hidden filed to your search form and include a different template based on that:

<form role="search" method="get" id="searchsupport" action="/">
    <label class="screen-reader-text" for="s">Search for:</label>
    <input type="text" onfocus="if (this.value == 'Search')  
    {this.value = '';}" onblur="if (this.value == '')  
    {this.value = 'search';}" id="s" name="s" value="search" class="search-form round"> 
    <input type="hidden" id="searchsubmit"> 

    <!-- this is the magic field --->
    <input type="hidden" name="custom_search" value="1"> 

    <input type='hidden' name='post_type' value='software, documents' />
</form>

then in your theme's search.php at the very top add:

if (isset($_GET['custom_search']) && $_GET['custom_search'] == 1){
   include('custom_search.php'); // change it to whatever template file you would like to use
   break;
}
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.