Skip to content

Instantly share code, notes, and snippets.

@sentisoft
Created September 30, 2013 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sentisoft/6766021 to your computer and use it in GitHub Desktop.
Save sentisoft/6766021 to your computer and use it in GitHub Desktop.
Custom search form
<aside id="pretraga-nekretnina" class="search-box-<?php bloginfo('language'); ?>">
<?php
// check if there are sales AND rentals
$property = get_posts(array('post_type' => 'property', 'post_status' => 'publish'));
?>
<?php
// get all gets
foreach($_GET as $name=>$value) {
$search_get[$name] = $value;
}
?>
<h3><?php _e('Prona&#273;i svoj novi dom', 'premiumre'); ?></h3>
<form method="get" action="<?php echo home_url( '/' ); ?>">
<input type="text" name="s" id="search-text" title="" class="text" value="+" style="display:none;" />
<label><?php _e('Odaberite tip nekretnine', 'premiumre'); ?></label>
<select name="tip" id="search-tip" class="text">
<option value=""><?php _e('Tip Nekretnine', 'premiumre'); ?></option>
<?php
$tips = apply_filters('search_tips_terms', get_terms('tip', array('hide_empty' => false, 'order' => 'DESC')) );
foreach($tips as $tip) {
echo '<option value="'.$tip->slug.'"'.selected($tip->slug, $search_get['tip'], false).'>'.$tip->name.'</option>';
}
?>
</select>
<label><?php _e('&#381;elim da', 'premiumre'); ?></label>
<select name="status" id="search-status" class="text">
<option value=""><?php _e('Status Nekretnine', 'premiumre'); ?></option>
<?php
$statusi = apply_filters('search_status_terms', get_terms('status', array('hide_empty' => true)) );
foreach($statusi as $status) {
echo '<option value="'.$status->slug.'"'.selected($status->slug, $search_get['status'], false).'>'.$status->name.'</option>';
}
?>
</select>
<div class="spavace_sobe">
<label><?php _e('Spava&#263;e sobe', 'premiumre'); ?></label>
<select name="broj_soba" id="search-broj_soba" class="text">
<option value=""><?php _e('Broj Soba', 'premiumre'); ?></option>
<?php
$broj_soba = apply_filters('broj_soba_options', array('1','1.5','2','2.5','3','3.5','4','4.5','5','5.5','6+'));
foreach($broj_soba as $broj_sobe) {
echo '<option'.selected($broj_sobe, $search_get['broj_soba'], false).'>'.$broj_sobe.'</option>';
}
?>
</select>
</div>
<div class="broj_kupatila">
<label><?php _e('Kupatila', 'premiumre'); ?></label>
<select name="broj_kupatila" id="search-broj_kupatila" class="text">
<option value=""><?php _e('Broj kupatila', 'premiumre'); ?></option>
<?php
$broj_kupatila = apply_filters('broj_kupatila_options', array('1','2','3','4','5','6+'));
foreach($broj_kupatila as $broj_kupatilo) {
echo '<option'.selected($broj_kupatilo, $search_get['broj_kupatila'], false).'>'.$broj_kupatilo.'</option>';
}
?>
</select>
</div>
<label><?php _e('Odaberite grad', 'premiumre'); ?></label>
<select name="grad" id="search-grad" class="text">
<option value=""><?php _e('Izaberite grad', 'premiumre'); ?></option>
<?php
$gradovi = apply_filters('search_gradovi_terms', get_terms('grad', array('hide_empty' => true)) );
foreach($gradovi as $grad) {
echo '<option value="'.$grad->slug.'"'.selected($grad->slug, $search_get['grad'], false).'>'.$grad->name.'</option>';
}
?>
</select>
<label><?php _e('Cena', 'premiumre'); ?></label>
<select name="cena" id="search-cena" class="text">
<option value=""><?php _e('Izaberite cenu', 'premiumre'); ?></option>
<?php
$cene = apply_filters('cena_options', array('0 - 49.999','50.000 - 99.999','100.000 - 499.999','500.000+'));
foreach($cene as $cena) {
echo '<option'.selected($cena, $search_get['cena'], false).'>'.$cena.'</option>';
}
?>
</select>
<input type="submit" id="search-submit" class="submit btn left" value="<?php _e('Prona&#273;i', 'premiumre'); ?>" />
</form>
</aside>
<div class="clearfix"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment