You have set “roll_number” custom field in tax_query. It should be in “meta_query”. Please try the updated code:
tion exam_result_filter_function(){
$args = array(
'post_type' => 'exam_result',
);
if( isset( $_POST['school_class'] ) || !empty( $_POST['academic_year']) || !empty( $_POST['roll_number']) ){
$args['tax_query'] = array(
'relation' => 'AND',
array(
'taxonomy' => 'school_class',
'field' => 'id',
'terms' => $_POST['school_class'],
),
array(
'taxonomy' => 'academic_year',
'field' => 'id',
'terms' => $_POST['academic_year'],
)
);
$args['meta_query'] = array(
array(
'key' => 'roll_number',
'value' => $_POST['roll_number'],
'compare' => 'IN',
),
);
}
$query = new WP_Query( $args );
print_r($args);
if( $query->have_posts() ) :
while( $query->have_posts() ): $query->the_post();
echo the_title();
endwhile;
wp_reset_postdata();
else :
get_template_part( 'no-results', 'page' );
endif;
die();
}
add_action('wp_ajax_myfilter', 'exam_result_filter_function');
add_action('wp_ajax_nopriv_myfilter', 'exam_result_filter_function');