I’m having an issue with a search form. I basically have 7 input fields used to search different properties. All of them apart from the last two see to be working, as soon as I introduce the last two (min price & max price) the form returns no results whereas if I take them out the equation the form works fine.
The query looks like this -
<?php
$_location = $_GET['location'] != '' ? $_GET['location'] : '';
$_status = $_GET['status'] != '' ? $_GET['status'] : '';
$_type = $_GET['type'] != '' ? $_GET['type'] : '';
$_minbed = $_GET['minbed'] != '' ? $_GET['minbed'] : '';
$_maxbed = $_GET['maxbed'] != '' ? $_GET['maxbed'] : '';
$_minprice = $_GET['minpay'] != '' ? $_GET['minpay'] : '';
$_maxprice = $_GET['maxprice'] != '' ? $_GET['maxprice'] : '';
// Start the Query
$property_args = array(
'post_type' => 'property-spaces',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'wpcf-location-area',
'value' => $_location,
'compare' => 'LIKE',
),
array(
'key' => 'wpcf-property-status',
'value' => $_status,
'compare' => 'LIKE',
),
array(
'key' => 'wpcf-property-type',
'value' => $_type,
'compare' => 'LIKE',
),
array(
'key' => 'wpcf-total-rooms',
'value' => $_minbed,
'compare' => '>=',
'type' => 'numeric',
),
array(
'key' => 'wpcf-total-rooms',
'value' => $_maxbed,
'compare' => '<=',
'type' => 'numeric',
),
array(
'key' => 'wpcf-min-room-price',
'value' => $_minprice,
'compare' => '>=',
'type' => 'numeric',
),
array(
'key' => 'wpcf-max-room-price',
'value' => $_maxprice,
'compare' => '<=',
'type' => 'numeric',
),
)
);
$propertySearchQuery = new WP_Query( $property_args );
if( $propertySearchQuery->have_posts() ) :
?>
This is new territory for me so I’m a bit lost, I’m guessing it’s something to do with the meta query as I’ve gone through and checked all variables and the names within the form.