multiple drop-down search form using custom fields and custom taxonomies [part 2]
///////////////////////////////////////////////////////////////
now we need to place the drop-down box where it belongs. so, open the theme-searchbar.php located in themes -> classipress -> includes - theme-searchbar.php . This is where the original search form is located. what we wanna do is replace this form with our new one, built upon our custom drop-down boxes. so, locate this piece of code :
<?php wp_dropdown_categories('show_option_all='.__('All Categories', 'appthemes').'&hierarchical='.get_option('cp_cat_h ierarchy').'&hide_empty='.get_option('cp_cat_hide_ empty').'&depth='.get_option('cp_search_depth').'& show_count='.get_option('cp_cat_child_count').'&or derby='.get_option('cp_cat_orderby').'&title_li=&u se_desc_for_title=1&tab_index=2&class=searchbar&ta xonomy=ad_cat'); ?>
and you replace it with this one:
<?php my_dropdown_categories('name=Location&taxonomy=ad_ location&hierarchical='.get_option('cp_cat_hierarc hy').'&hide_empty=1&depth='.get_option('cp_search_ depth').'&show_count='.get_option('cp_cat_child_co unt').'&orderby='.get_option('cp_cat_orderby').'&t itle_li=&use_desc_for_title=1&tab_index=1&class=se archbar&show_option_all='.__('All locations','appthemes').'&show_option_none='.__('C hoose a location','appthemes').'&selected=-1'); ?>
what we did here is replace the initial drop-down box built upon appthemes' function with a new one using our tweaked version of appthemes' function ( the my_dropdown_categories function ). notice the 'name' and 'taxonomy' parameters in this new function: they should hold your own custom values (Location and ad_location in this instance). the 'hide_empty' parameter sets whether the drop-down box should not display empty categories (1 being the equivalent of 'yes' and 0 being 'no').
to have multiple drop-down boxes all you need to do is paste in the above code snippet as many times as you'd like to have drop-down boxes, making sure to change the name and taxonomy parameters to fit the specific taxonomy you want to be displayed in the drop-down box.
now let's style this up! this is where the 'name' parameter plays its role since it will be used as the identifier of the styling class to be used for the corresponding drop-down box. paste the following css code anywhere in your style.css (preferably at the bottom):
.form_search select#Location.searchbar{float:right; border:1px solid #BBB; min-height:15px; min-width:70px; padding:7px;font-size:17px;color:#666666;-khtml-border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; line-height: 33px;}
you should have noticed the "select#Location" part, where we link this styling rule to the specific drop-down box with the same name 'Location' (these names are case-sensitive).
at this point you should have a drop-down box filled with the values of your custom field 'location', styled just like the 'original' categories drop-down and holding the 'terms' of your 'ad_location' taxonomy (that is the terms that have been used in any given ad posting).
///////////////////////////////////////////////////////////////////////////////////////////