Home › Forums › General Issues › Multi Select – Get all choices for Query Args › Reply To: Multi Select – Get all choices for Query Args
// Variables
$number_of_events = get_field( 'number_of_events' );
// print_r($number_of_events);
$event_object = get_field_object('events_category');
// print_r($event_object);
$event_cat_name = $event_object['value'];
// print_r($event_cat_name);
$cat_names = array_column($event_cat_name, 'slug');
print_r($cat_names);
// $event_cat_slug = $event_cat_name[0]->slug;
// print_r($event_cat_slug);
$args = array(
'post_type' => 'event',
'posts_per_page' => $number_of_events,
'tax_query' => array(
array(
'taxonomy' => 'event_category',
'terms' => $cat_names
)
)
);
Still does not filter though $cat_names
does print cats selected in multi select like when I choose onsite only: Array ( [0] => onsite )
terms should accept an array I understand but JS states
Error: Syntax error, unrecognized expression: Array
(
[0] => onsite
)
<h2>Event 4 Virtual</h2>
<h2>Event 3</h2>
<h2>Event Two</h2>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.