How to Use Multiple Search Forms In WordPress

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<input type="text" value="" name="s" id="s" />
<input type="hidden" name="search-type" value="normal" />
<input name="submit" type="submit" value="Go" />
</form>



<?php
if(isset($_GET['search-type'])) {
    $type = $_GET['search-type'];
    if($type == 'random') {
        load_template(TEMPLATEPATH . '/normal-search.php');
    } elseif($type == 'books') {
        load_template(TEMPLATEPATH . '/books-search.php');
    }
}
?>
$args = array( 'post_type' => 'post' );
$args = array_merge( $args, $wp_query->query );
query_posts( $args );

$args = array( 'post_type' => 'books' );
$args = array_merge( $args, $wp_query->query );
query_posts( $args );

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s