sort options for search results

I have a search for specific categories posts, the category is called archive, and am wondering if after they are displayed they can be sorted by either most recent or most relevant via a dropdown. The code I am using for the search is

<form method=”get” id=”searchform” action=”<?php echo home_url( ‘/’ ); ?>”
class=”search-form results” role=”search”>
<span class=”screen-reader-text”>Search the Blog</span>
<span class= “searchHead”>Search the Blog</span>
<input type=”search” class=”search-field” placeholder=”Enter Text” value=””
<input type=”image” src=”/wp-content/themes/vicap/img/search.png” alt=”Search”
class=”search-submit” value=”Go”>
<input type=”hidden” name=”search-type” value=”archive” />

that then takes me to search.php where I have

if(isset($_GET[‘search-type’])) {
$type = $_GET[‘search-type’];
if($type == ‘blog’) {
load_template(TEMPLATEPATH . ‘/blog-search.php’);
} elseif($type == ‘archive’) {
load_template(TEMPLATEPATH . ‘/archive-search.php’);


which takes me to a a specific template. I’m not sure if any of this code is relevant to my question but thought it may be helpful. I want to re-order/sort the list of search results once they are populated.

Read more here:: sort options for search results

Leave a Reply

Your email address will not be published. Required fields are marked *