1

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>
3

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.