I’ve a search type that has 3 taxonomy fields and one publish meta discipline. The shape works properly once I use taxonomy fields. However once I use the publish meta discipline, all posts are displayed.
The place is the issue with my code?
add_filter('query_vars', 'register_query_vars');
perform register_query_vars($vars)
{
$vars[] .= 'state';
$vars[] .= 'metropolis';
$vars[] .= 'loc';
$vars[] .= 'identify';
$vars[] .= 'standing';
return $vars;
}
add_action('pre_get_posts', 'main_search_query');
perform main_search_query($question)
{
if ($query->is_post_type_archive('property') && $query->is_main_query() && !is_admin()) {
$identify = get_query_var('identify', FALSE);
$standing = get_query_var('standing', FALSE);
$state = get_query_var('state', FALSE);
$metropolis = get_query_var('metropolis', FALSE);
$loc = get_query_var('loc', FALSE);
$status_query = array('relation' => 'AND');
$standing ? array_push($status_query, array('meta_query' => array( array( 'key' =>'_status', 'worth' => $standing, 'evaluate' => 'LIKE' )))) : null;
$query->set('meta_query', $status_query);
$tax_query = array('relation' => 'AND');
$allofcity = ($metropolis == 0) ? array('taxonomy' => 'add_prm', 'discipline' => 'temr_id', 'phrases' => $state) : array('taxonomy' => 'add_prm', 'discipline' => 'term_id', 'guardian' => $state, 'phrases' => $metropolis);
$state ? array_push($tax_query, $allofcity) : null;
$metropolis ? array_push($tax_query, array('taxonomy' => 'add_prm', 'discipline' => 'term_id', 'phrases' => $metropolis)) : null;
$loc ? array_push($tax_query, array('taxonomy' => 'add_cat', 'discipline' => 'term_id', 'phrases' => $loc)) : null;
$identify ? array_push($tax_query, array('taxonomy' => 'add_name', 'discipline' => 'term_id', 'phrases' => $identify)) : null;
$query->set('tax_query', $tax_query);
}
}