Support

Account

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[0];
    $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[1];
    $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[2];
    $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 )
        )
      ))
    ) ;