File: /home/reachcon/public_html/wp-content/themes/reach-connects/directory-search.php
<div class="callout trans">
<form method="get" class="searchForm" action="<?php echo get_home_url().'/'.$omadaClient->args['post_type']['args']['rewrite']['slug'].'/';?>">
<div class="grid-x grid-padding-x large-up-4 medium-up-2">
<div class="cell">
<label>Business Category</label>
<select id="category" name="busCat">
<option value="all">All Categories</option>
<?php
$terms = get_terms( 'categories', array( 'hide_empty' => true ));
if(!empty($terms)){
foreach($terms as $term){
$s = (isset($_GET['busCat']) && $_GET['busCat']==$term->slug) ? ' selected' : '';
echo '<option value="'.$term->slug.'"'.$s.'>'.$term->name.'</option>';
}
}
?>
</select>
</div>
<div class="cell">
<label>Donation Category</label>
<select id="donCat" name="donCat">
<option value="all">All Categories</option>
<?php
$terms = get_terms( 'donation_category', array( 'hide_empty' => true ));
if(!empty($terms)){
foreach($terms as $term){
$s = (isset($_GET['donCat']) && $_GET['donCat']==$term->slug) ? ' selected' : '';
echo '<option value="'.$term->slug.'"'.$s.'>'.$term->name.'</option>';
}
}
?>
</select>
</div>
<div class="cell">
<label>Country</label>
<select id="country" name="country">
<option value="all">All Countries</option>
<option value="US">United States</option>
</select>
<div id="stateEnclosure" style="display:none">
<label>State</label>
<select id="state" name="state">
<option value="all">All States</option>
<?php
$stateArray = array('AL'=>'Alabama','AK'=>'Alaska','AZ'=>'Arizona','AR'=>'Arkansas','CA'=>'California','CO'=>'Colorado','CT'=>'Connecticut','DE'=>'Delaware','DC'=>'District of Columbia','FL'=>'Florida','GA'=>'Georgia','HI'=>'Hawaii','ID'=>'Idaho','IL'=>'Illinois','IN'=>'Indiana','IA'=>'Iowa','KS'=>'Kansas','KY'=>'Kentucky','LA'=>'Louisiana','ME'=>'Maine','MD'=>'Maryland','MA'=>'Massachusetts','MI'=>'Michigan','MN'=>'Minnesota','MS'=>'Mississippi','MO'=>'Missouri','MT'=>'Montana','NE'=>'Nebraska','NV'=>'Nevada','NH'=>'New Hampshire','NJ'=>'New Jersey','NM'=>'New Mexico','NY'=>'New York','NC'=>'North Carolina','ND'=>'North Dakota','OH'=>'Ohio','OK'=>'Oklahoma','OR'=>'Oregon','PA'=>'Pennsylvania','RI'=>'Rhode Island','SC'=>'South Carolina','SD'=>'South Dakota','TN'=>'Tennessee','TX'=>'Texas','UT'=>'Utah','VT'=>'Vermont','VA'=>'Virginia','WA'=>'Washington','WV'=>'West Virginia','WI'=>'Wisconsin','WY'=>'Wyoming');
$states=array();
$args = array( 'post_type' => $omadaClient->args['post_type']['slug'], 'numberposts' => -1 );
$query = new WP_Query( $args );
if ( $query->have_posts() ) { while ( $query->have_posts() ){ $query->the_post();
$state=get_field('state');
if(isset($stateArray[$state])){$states[]=$state;}
} }
if(!empty($states)){
$states = array_unique($states);
sort($states);
foreach($states as $state){
$s = (isset($_GET['state']) && $_GET['state']==$state) ? ' selected' : '';
echo '<option value="'.$state.'"'.$s.'>'.$stateArray[$state].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="cell">
<label>Keyword Search</label>
<input type="text" name="search" >
</div>
</div>
<div class="text-center">
<input type="submit" value="Search" class="button small nm min25">
</div>
</form>
</div>