I have some problems with wordpress meta key relations and search parametrs. I can not get this to work:
?meta_value=DažÄdi&id=32&cp_city=CÄsis
Search results is only filtering by meta_value, not of cp_city and meta_value.
cp_city is also meta key value.
But this call is working and filtering:
?meta_value=PÄrdod&id=32
I need to filter by two or three parametrs.
Here is functions code to filter.
<?php
if (empty($pilseta)) {
$args=array(
'post_type' => 'ad_listing',
'post_status' => 'publish',
'meta_key' => 'cp_tips',
'meta_value' => $meta,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'ad_cat',
'terms' => $cat_id,
'field' => 'id'
)
)
);
}
else {
$args=array(
'post_type' => 'ad_listing',
'post_status' => 'publish',
'meta_query' => array(
array(
'meta_key' => 'cp_tips',
'meta_value' => $meta
),
array(
'meta_key' => 'cp_city',
'meta_value' => $pilseta
),
),
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'ad_cat',
'terms' => $cat_id,
'field' => 'id'
)
)
);
}
query_posts($args);
?>
Does you saw the SQL query generated by WordPress to know if is ok?
After query_posts call, puts this:
If what WP is writing an unexpected query, I advice you to use posts_where filter with get_posts instead of query_posts
Change the meta_key args file below and try: