As on the title Im loooking to make a search form in wordpress using a select dropdown to search the normal wordpress posts and also a custom post type.
The normal posts has a different look and I have a custom post type wich has vertical thumbnails
I figuret the search results out using this function
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'gallery' )
{
return locate_template('taxonomy-gallery.php');
}
return $template;
}
add_filter('template_include', 'template_chooser');
but my problem is in the search form
the default search form to search default wordpress posts is this one:
<div class="searchbox">
<form action="<?php echo home_url( '/' ); ?>" method="get"><button name="search" class="button">
<span></span></button>
<input type="text" id="s" name="s" value="" />
</form>
</div>
by adding <input type="hidden" name="post_type" value="gallery" />
I can get search results of gallery via taxonomy-gallery.php
so my last search form code is this one
<div class="searchbox">
<form action="<?php echo home_url( '/' ); ?>" method="get"><button name="search" class="button">
<span></span></button>
<input type="text" id="s" name="s" value="" />
<input type="hidden" name="post_type" value="gallery" />
</form>
</div>
but I want to add a select in search input that makes me to choose what I want to search posts or custom post type (gallery)
for example you can check this image
I hope I find any help here thankyou very much.
Selection dropdowns can be made this way: