Home › Forums › Add-ons › Repeater Field › Turn repeater subfields into variables › Reply To: Turn repeater subfields into variables
I got it working. As what I had above was showing the taxonomy term IDs I found how to turn these IDs into text terms that could be used within $the_query $terms array. I’m not sure if this is the best way to solve the problem so if you know any way to streamline this code, I’d greatly appreciate knowing how.
global $post; $row1 = get_field('homepage_sidebar_sponsor_logos' ); $first_row = $row1; $first_row_id = $first_row['contestant_year_category' ]; $first_row_term = get_term_by('id', absint( $first_row_id ), 'year_type'); $first_row_name = $first_row_term->name; $row2 = get_field('homepage_sidebar_sponsor_logos' ); $second_row = $row2; $second_row_id = $second_row['contestant_year_category' ]; $second_row_term = get_term_by('id', absint( $second_row_id ), 'year_type'); $second_row_name = $second_row_term->name; $row3 = get_field('homepage_sidebar_sponsor_logos' ); $third_row = $row3; $third_row_id = $third_row['contestant_year_category' ]; $third_row_term = get_term_by('id', absint( $third_row_id ), 'year_type'); $third_row_name = $third_row_term->name; $the_query = new WP_Query( array( 'post_type' => 'contestants', 'tax_query' => array( array( 'taxonomy' => 'year_type', 'field' => 'slug', 'terms' => array( $first_row_name, $second_row_name, $third_row_name ) ) )) ) ;
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!
🗓️ Just one more day until the next session of ACF Chat Fridays! Make sure to register for the latest updates on what’s coming in ACF 6.1!— Advanced Custom Fields (@wp_acf) March 30, 2023
📆 Friday 31st March 3pm UTC
👉 Register here - https://t.co/3UtvQbDwNm pic.twitter.com/7xtEJakeQN
© 2023 Advanced Custom Fields.