Home › Forums › General Issues › Multi Select – Get all choices for Query Args › Reply To: Multi Select – Get all choices for Query Args
Do now have this
// Variables
$number_of_events = get_field( 'number_of_events' );
// print_r($number_of_events);
$terms = get_field('events_category');
$term_slugs ='';
foreach ( $terms as $term ):
$term_slugs .= esc_html( $term->slug ) . ',';
endforeach;
echo $term_slugs;
which almost works for loading this is terms => array(terms)
:
$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($term_slugs),
],
);
but I need a comma after each term except for the last one
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.