I created a custom search where i am able to show the Fields (ACF fields) and also Taxonomies. But while I am searching by taking the combination of both Taxonomies and meta fields, i am not getting the results. It is giving the results if i will search either Taxonomies or meta fields. How to make both conditions work together?
This is my code where i mentioned both meta_query and tax_query:-
<?php
if($_POST){
$_speciality = $_POST['speciality'] != '' ? $_POST['speciality'] : '';
$_students_last_name = $_POST['students_last_name'] != '' ? $_POST['students_last_name'] : '';
if($_speciality!=" "){
$param1 = array(
'key' => 'speciality',
'compare' => '=',
'value' => $_speciality
);
} else{
$param1 = "";
}
if($_students_last_name!=" "){
$param2=array(
'key' => 'students_last_name',
'compare' => 'LIKE',
'value' => $_students_last_name
);
} else{
$param2="";
}
$args = array(
'post_type' => 'students',
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'Music',
'field' => 'slug',
'terms' => $param1
)
),
'meta_query' => array(
'relation' => 'AND',
$param2
),
);
} else {
$args = array(
'post_type' => 'students',
'orderby' => 'date',
'order' => 'DESC'
);
}
$the_query = new WP_Query( $args );