I’m having some trouble querying multiple custom fields. I have created a custom search form that the values are posted to the query. It’s working, but it’s only querying the 1 value. Here is the code:
<?php
$bedrooms = $_GET['bedrooms'];
$bathrooms = $_GET['bathrooms'];
$bedroom_key = 'bedrooms';
$bathroom_key = 'bedrooms'
?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array(
'post_type' => 'property',
'posts_per_page' => '2',
'paged' => $paged,
'meta_query' => array(
array(
'key' => $bedroom_key,
'value' => $bedrooms,
'compare' => '>='
),
array(
'key' => $bathroom_key,
'value' => $bathrooms,
'compare' => '>='
)
)
) );?>
So really, this query is only getting the posts that match the “bedrooms” but not the “bathrooms”. This is live at http://www.bayofplenty.info