Home › Forums › General Issues › Multi Select – Get all choices for Query Args › Reply To: Multi Select – Get all choices for Query Args
Saw something funny happening to the quotes so used decimal code for quotes:
// Variables
$number_of_events = get_field( 'number_of_events' );
// print_r($number_of_events);
$terms = get_field('events_category');
// print_r($terms);
// $term_slugs = $terms()->slug;
$term_slugs ='';
foreach ( $terms as $term ):
$term_slugs .= "'" . esc_html( $term->slug ) . "'" . ',';
endforeach;
$term_slugs = substr($term_slugs, 0, -1); //Removes very last comma.
// print_r($term_slugs);
// local,virtual,
$args = array(
'post_type' => 'event',
'posts_per_page' => $number_of_events,
// 'event_category' => $term_slugs
'tax_query' => [
'taxonomy' => 'event_category',
'include_children' => false,
'field' => 'name',
// 'terms' => array_values($term_slugs),
],
);
still no filtering on event category..
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.