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!
© 2022 Advanced Custom Fields.