forked from vanbexlabs/hackathon-wordpress-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchbar-event.php
38 lines (35 loc) · 1.5 KB
/
searchbar-event.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<div class="sub-bar search-bar">
<div class="container cf">
<form role="search" method="get" id="event-searchform" action="<?php bloginfo('home'); ?>/events">
<div>
<input type="text" placeholder="Enter a city or state and hit enter..." name="s" id="s" class="search-input"<?php if(is_search()) { echo ' value="' . get_search_query() . '"'; } ?> />
<input type="submit" id="searchsubmit" value="Search" />
<?php
function get_terms_dropdown($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$optionname = "event-type";
$emptyvalue = "0";
$output ="<div class='select-wrapper'><select name='".$optionname."'><option selected='".$selected."' value='".$emptyvalue."'>Select event type</option>'";
foreach($myterms as $term){
$term_taxonomy=$term->event-type;
$term_slug=$term->slug;
$term_name =$term->name;
$link = $term_slug;
if (is_tax('event-type',$term_slug)) {
$selected = "selected";
} else {
$selected = "";
}
$output .="<option name='".$link."' value='".$link."' " . $selected . ">".$term_name."</option>";
}
$output .="</select></div>";
return $output;
}
$taxonomies = array('event-type');
$args = array('order'=>'ASC','hide_empty'=>true);
echo get_terms_dropdown($taxonomies, $args);
?>
</div>
</form>
</div>
</div>