Attempting to question primarily based on type submission. One choose on the shape is constructed with:
wp_dropdown_categories( 'title=specialty&taxonomy=specialties&orderby=title&show_option_none=Choose a Specialty&show_none_value=-1&chosen='.$p_specialty );
The specialty worth is then grabbed and an array created:
if (isset($_GET['specialty']) && !empty($_GET['specialty']) && $_GET['specialty'] > 0 ) {
$specialty = true;
++$qs_count;
$p_specialty = $_GET['specialty'];
$p_specialty_array = array (
'key' => 'specialties',
'worth' => $p_specialty,
'evaluate' => 'LIKE',
);
$term_specialty = get_term($p_specialty);
$term_specialty = $term_specialty->title;
}
$p_specialty_array is then utilized in:
$meta_query = array (
'relation' => 'AND',
array (
'q_last' => array (
'key' => 'provider_name_last_name',
),
'q_first' => array (
'key' => 'provider_name_first_name',
),
'evaluate' => 'IN',
$p_fname_array,
$p_lname_array,
$p_new_array,
$p_gender_array,
$p_clinic_array,
$p_specialty_array,
),
);
However this causes an issue as a result of the ID of 1 specialty is 20 and one other is 204. When the shape is submitted for specialty=20 utilizing evaluate=LIKE it returns posts the place specialty is both 20 or 204 (moderately than simply 20).
After I change the evaluate to “=“, nothing is returned although there are posts the place specialty=20.
I’ve additionally tried including value_field=‘slug’ to the wp_dropdown_categories, however can’t determine how one can make that work (it could work and I simply don’t know how one can write the array when utilizing the slug).
I would definitely favor a technique the place it solely will get “=“ values rather than “LIKE” to keep away from points like this, however can’t get it to work.
How do I make this work with evaluate "=", or one thing else, the place I get solely the specialty chosen?
Replace
I’ve tried the next only for kicks and all present empty outcomes:
if (isset($_GET['specialty']) && !empty($_GET['specialty']) && $_GET['specialty'] > 0 ) {
$specialty = true;
++$qs_count;
$p_specialty = $_GET['specialty'];
$p_spec_minus = $p_specialty - 1;
$p_specialty_plus = $p_specialty + 1;
echo 'plus: '.$p_specialty_plus;
$p_specialty_array = array (
'key' => 'specialties',
'worth' => array( $p_spec_minus, $p_specialty_plus),
'evaluate' => 'BETWEEN',
);
$term_specialty = get_term($p_specialty);
$term_specialty = $term_specialty->title;
}
On this subsequent one I attempted hardcoding the 20, however similar empty outcomes:
if (isset($_GET['specialty']) && !empty($_GET['specialty']) && $_GET['specialty'] > 0 ) {
$specialty = true;
++$qs_count;
$p_specialty = $_GET['specialty'];
echo 'plus: '.$p_specialty_plus;
$p_specialty_array = array (
'key' => 'specialties',
'worth' => '20',
'evaluate' => '=',
);
$term_specialty = get_term($p_specialty);
$term_specialty = $term_specialty->title;
}
I am very confused as to why this is not working.