Skip to content

Instantly share code, notes, and snippets.

@contempoinc
Created November 3, 2015 20:38
Show Gist options
  • Save contempoinc/c4c6b68ed13b7d274774 to your computer and use it in GitHub Desktop.
Save contempoinc/c4c6b68ed13b7d274774 to your computer and use it in GitHub Desktop.
RE7 Advanced Search with Price Low to High by default
<?php
/**
* Advanced Search Template
*
* @package WP Pro Real Estate 7
* @subpackage Template
*/
global $ct_options;
$ct_search_title = isset( $ct_options['ct_home_adv_search_title'] ) ? $ct_options['ct_home_adv_search_title'] : '';
$ct_home_adv_search_fields = isset( $ct_options['ct_home_adv_search_fields']['enabled'] ) ? $ct_options['ct_home_adv_search_fields']['enabled'] : '';
?>
<?php if(!empty($ct_search_title)) { ?>
<h4 class="marT0 marB0"><?php echo esc_html($ct_search_title); ?></h4>
<?php } ?>
<form id="advanced_search" name="search-listings" action="<?php echo home_url(); ?>">
<?php
if ($ct_home_adv_search_fields) :
foreach ($ct_home_adv_search_fields as $field=>$value) {
switch($field) {
// Type
case 'type' : ?>
<div class="left">
<label for="ct_type"><?php _e('Type', 'contempo'); ?></label>
<?php ct_search_form_select('property_type'); ?>
</div>
<?php
break;
// City
case 'city' : ?>
<div class="left">
<label for="ct_city"><?php _e('City', 'contempo'); ?></label>
<?php ct_search_form_select('city'); ?>
</div>
<?php
break;
// State
case 'state' : ?>
<div class="left">
<label for="ct_state"><?php _e('State', 'contempo'); ?></label>
<?php ct_search_form_select('state'); ?>
</div>
<?php
break;
// Zipcode
case 'zipcode' : ?>
<div class="left">
<?php
global $ct_options;
$ct_zip_or_post = isset( $ct_options['ct_zip_or_post'] ) ? $ct_options['ct_zip_or_post'] : '';
if($ct_zip_or_post == 'postcode') { ?>
<label for="ct_zipcode"><?php _e('Postcode', 'contempo'); ?></label>
<?php } else { ?>
<label for="ct_zipcode"><?php _e('Zipcode', 'contempo'); ?></label>
<?php } ?>
<?php ct_search_form_select('zipcode'); ?>
</div>
<?php
break;
// Country
case 'country' : ?>
<div class="left">
<label for="ct_country"><?php _e('Country', 'contempo'); ?></label>
<?php ct_search_form_select('country'); ?>
</div>
<?php
break;
// Community
case 'type' : ?>
<div class="left">
<label for="ct_community"><?php _e('Community', 'contempo'); ?></label>
<?php ct_search_form_select('community'); ?>
</div>
<?php
break;
// Beds
case 'beds' : ?>
<div class="left">
<label for="ct_beds"><?php _e('Beds', 'contempo'); ?></label>
<?php ct_search_form_select('beds'); ?>
</div>
<?php
break;
// Baths
case 'baths' : ?>
<div class="left">
<label for="ct_baths"><?php _e('Baths', 'contempo'); ?></label>
<?php ct_search_form_select('baths'); ?>
</div>
<?php
break;
// Status
case 'status' : ?>
<div class="left">
<label for="ct_status"><?php _e('Status', 'contempo'); ?></label>
<?php ct_search_form_select('ct_status'); ?>
</div>
<?php
break;
// Additional Features
case 'additional_features' : ?>
<div class="left">
<label for="ct_additional_features"><?php _e('Addtional Features', 'contempo'); ?></label>
<?php ct_search_form_select('additional_features'); ?>
</div>
<?php
break;
// Community
case 'community' : ?>
<div class="left">
<label for="ct_community"><?php _e('Community', 'contempo'); ?></label>
<?php ct_search_form_select('community'); ?>
</div>
<?php
break;
// Price From
case 'price_from' : ?>
<div class="left">
<label for="ct_price_from"><?php _e('Price From', 'contempo'); ?> (<?php ct_currency(); ?>)</label>
<input type="text" id="ct_price_from" class="number" name="ct_price_from" size="8" placeholder="<?php esc_html_e('Price From', 'contempo'); ?> (<?php ct_currency(); ?>)" />
</div>
<?php
break;
// Price To
case 'price_to' : ?>
<div class="left">
<label for="ct_price_to"><?php _e('Price To', 'contempo'); ?> (<?php ct_currency(); ?>)</label>
<input type="text" id="ct_price_to" class="number" name="ct_price_to" size="8" placeholder="<?php esc_html_e('Price To', 'contempo'); ?> (<?php ct_currency(); ?>)" />
</div>
<?php
break;
// MLS
case 'mls' : ?>
<div class="left">
<label for="ct_mls"><?php _e('Property ID', 'contempo'); ?></label>
<input type="text" id="ct_mls" name="ct_mls" size="12" placeholder="<?php esc_html_e('Property ID', 'contempo'); ?>" />
</div>
<?php
break;
// Number of Guests
case 'numguests' : ?>
<div class="left">
<label for="ct_rental_guests"><?php _e('Number of Guests', 'contempo'); ?></label>
<input type="text" id="ct_rental_guests" name="ct_rental_guests" size="12" placeholder="<?php esc_html_e('Number of Guests', 'contempo'); ?>" />
</div>
<?php
break;
}
} endif; ?>
<input type="hidden" name="search-listings" value="true" />
<input type="hidden" name="ct_orderby" value="priceASC" />
<?php
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if(is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
$lang = ICL_LANGUAGE_CODE;
// echo '<input type="hidden" name="lang" value="' . $lang . '" />';
}
?>
<input id="submit" class="btn left" type="submit" value="<?php esc_html_e('Search', 'contempo'); ?>" />
<div class="left makeloading"><i class="fa fa-circle-o-notch fa-spin"></i></div>
<div class="clear"></div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment