guid ) ){ $form_action = $post->guid; }else{ $form_action = ''; } //MIN(pm.meta_value) as minimum,MAX(pm.meta_value) as maximum /* $priceLimitArray = $wpdb->get_results('SELECT pm.meta_value FROM '.$wpdb->prefix.'postmeta AS pm WHERE pm.meta_key="cf_apartment_rent_month" AND pm.meta_value>="1000" ORDER BY pm.meta_value DESC'); echo '
'; print_r( $priceLimitArray );echo '';exit; */ $priceLimitArray = $wpdb->get_results('SELECT GROUP_CONCAT(pm.meta_value) as minimum FROM '.$wpdb->prefix.'postmeta AS pm WHERE pm.meta_key="cf_apartment_rent_month"'); if( !empty( $priceLimitArray )){ $priceArray = explode(',',$priceLimitArray[0]->minimum); // echo '
'; print_r( $priceArray );echo '';exit; $priceMin = min( $priceArray ); $priceMax = max( $priceArray ); }else{ $priceMin = 1000; $priceMax = 5000; } $priceStartSlot = $priceMin; $priceEndSlot = $priceMin+100; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if(isset($_REQUEST[ 'keyword' ])){ // echo '
'; print_r( $_POST );echo '';exit; // Get all search parameters $search_string = (isset( $_REQUEST['keyword']))?$_REQUEST['keyword']:''; $selected_bedrooms = (isset( $_REQUEST['bedrooms']))?$_REQUEST['bedrooms']:''; $selected_styles = (isset( $_REQUEST['style']))?$_REQUEST['style']:''; $selected_locations = (isset( $_REQUEST['location']))?$_REQUEST['location']:''; $selected_bathrooms = (isset( $_REQUEST['bathrooms']))?$_REQUEST['bathrooms']:''; $order_by_value = (isset( $_REQUEST['order_by_value']))?$_REQUEST[ 'order_by_value']:''; $abr_price_range = (isset( $_REQUEST['abr_price_range']))?$_REQUEST[ 'abr_price_range']:''; $metaQueryArray[ 'relation' ] = 'AND'; $taxQueryArray[ 'relation' ] = 'AND'; if( !empty( $abr_price_range )){ $priceRangeArray = explode( ',', $abr_price_range ); $priceStartSlot = $priceRangeArray[0]; $priceEndSlot = $priceRangeArray[1]; } $paginationPerPage = get_option('abr_searchPaginationNumber', false); if( empty($paginationPerPage ) ){ $paginationPerPage = '-1'; } $args = array( 'posts_per_page'=> $paginationPerPage, 'post_type'=> 'apartment', 'paged' => $paged, 's' => $search_string ); if( !empty( $order_by_value )){ $orderArray = explode( '_',$order_by_value ); if( $orderArray[0] == 'date'){ $args['orderby'] = 'date'; }else if( $orderArray[0] == 'price'){ $args['orderby'] = 'cf_apartment_rent_month'; }else{ $args['orderby'] = 'post_title'; } $args['order'] = $orderArray[1]; // echo '
'; print_r( $args ); exit;
}
if( !empty( $selected_styles )){
$style_tax = build_tax_array( 'apartment_style',$selected_styles );
$taxQueryArray[] = $style_tax;
}else{
$taxQueryArray[] = '';
}
if( !empty( $selected_bedrooms )){
$bedroom_tax = build_tax_array( 'apartment_bedrooms',$selected_bedrooms);
$taxQueryArray[] = $bedroom_tax;
}else{
$taxQueryArray[] = '';
}
if( !empty( $selected_bathrooms )){
$bathroom_tax = build_tax_array( 'apartment_bathrooms',$selected_bathrooms);
$taxQueryArray[] = $bathroom_tax;
}else{
$taxQueryArray[] = '';
}
if( !empty( $priceRangeArray )){
$price_min_tax = array(
'key' => 'cf_apartment_rent_month',
'value' => (int)$priceRangeArray[0],
'compare' => '>=',
'type' => 'NUMERIC'
);
$metaQueryArray[] = $price_min_tax;
$price_max_tax = array(
'key' => 'cf_apartment_rent_month',
'value' => (int)$priceRangeArray[1],
'compare' => '<=',
'type' => 'NUMERIC'
);
$metaQueryArray[] = $price_max_tax;
}else{
$price_min_tax = '';
$price_max_tax = '';
}
$args['tax_query'] = $taxQueryArray;
$args['meta_query'] = $metaQueryArray;
/*
array(
'relation' => 'AND',$style_tax,$bedroom_tax,$price_min_tax,$price_max_tax
);
*/
}
$apartment_style = '';
$apartment_bedrooms = '';
// Get All Bedrooms
$all_bedrooms = get_terms( array(
'taxonomy' => 'apartment_bedrooms',
'hide_empty' => false,
));
// Get Apartment Styles
$all_styles = get_terms( array(
'taxonomy' => 'apartment_style',
'hide_empty' => false,
));
// Get Community Location
$community_locations = get_terms( array(
'taxonomy' => 'community_location',
'hide_empty' => false,
));
// Get All Bathrooms
$all_bathrooms = get_terms( array(
'taxonomy' => 'apartment_bathrooms',
'hide_empty' => false,
));
?>
'; print_r( $args ); echo '';// exit;
// The Query
$searchObject = new WP_Query( $args );
// Print last SQL query string
// echo $wpdb->last_query;exit;
if( !empty( $searchObject->found_posts)){
?>
found_posts; ?> Listings
'; print_r( $searchObject->posts ); exit;
foreach( $searchObject->posts as $post ){
$aID = $post->ID;
$apartmentThumnail = get_post_meta( $aID, 'cf_apartment_pic',true );
if( empty( $apartmentThumnail )){
$apartmentThumnail = '';
}
$apartmentUrl = get_permalink( $aID );
$apartmentRent = get_post_meta( $aID, 'cf_apartment_rent_month',true );
$aBedrooms = wp_get_post_terms($aID,'apartment_bedrooms');
$aBedroom = (isset($aBedrooms[0]->name))?$aBedrooms[0]->name:0;
$aBathrooms = wp_get_post_terms($aID,'apartment_bathrooms');
$aBathroom = (isset($aBathrooms[0]->name))?$aBathrooms[0]->name:0;
$aPlotAreas = wp_get_post_terms($aID,'apartment_area');
$aPlotArea = (isset($aPlotAreas[0]->name))?$aPlotAreas[0]->name:0;
$capacities = wp_get_post_terms($aID,'apartment_rental_occupancy');
$capacity = (isset($capacities[0]->name))?$capacities[0]->name:0;
$cmid = get_post_meta($aID,'cf_apartment_community',true);
$cmAdress = get_post_meta($cmid,'cf_community_address',true);
$data = getLatLong( $cmAdress );
?>
$
/ per Month
For Rent
post_content; ?>More info
Beds: 4
Baths: 4
Plot Size: 1800 m²
Living Area: 485 m²
Terrace: 65 m²
Parking: Garages
Heating: Central
Built in: 2005
Beds:
Baths:
Plot Size:
Capacity:
$search_string,'bedrooms'=>$selected_bedrooms );
$pagination_argument['style'] = $selected_styles;
$pagination_argument['location'] = $selected_locations;
$pagination_argument['bathrooms'] = $selected_bathrooms;
$pagination_argument['abr_price_range'] = $abr_price_range;
$pagination_argument['order_by_value'] = $order_by_value;
$baseUrl = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );
if(!empty( strpos( get_pagenum_link( $big ), 'keyword' ) ) ){
$baseArray = explode( 'keyword', $baseUrl );
$baseUrl = $baseArray[0];
}
$paginationArray = array(
'base' => $baseUrl,
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $searchObject->max_num_pages,
'add_args'=> $pagination_argument,
'type' => 'array'
);
// esc_url( get_pagenum_link( $big ) )
$pages = paginate_links( $paginationArray );
//kriesi_pagination( $searchObject->max_num_pages,2 );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '';
foreach ( $pages as $page ) {
echo "- $page
";
}
echo '
';
}
?>
$type,
'field' => 'slug',
'terms' => array( $value )
);
return $response;
}
function kriesi_pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "«";
if($paged > 1 && $showitems < $pages) echo "‹";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "".$i."":"".$i."";
}
}
if ($paged < $pages && $showitems < $pages) echo "›";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "»";
echo "\n";
}
}