Support

Account

Home Forums Add-ons Repeater Field Repeater Query: getting just that row's sub fields

Solved

Repeater Query: getting just that row's sub fields

  • I have a repeater query as directed in Section 4 on this page:https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    I now can’t get just the sub fields within that row. What am I doing wrong?

    <?php 
    
    // Unique ID from ACF
    $uniqueID = $_POST['uniqueID'];
    
    // filter
    function my_posts_where( $where ) {
      
      $where = str_replace("meta_key = 'projects_$", "meta_key LIKE 'projects_%", $where);
    
      return $where;
    }
    
    add_filter('posts_where', 'my_posts_where');
    
    // args
    $args = array(
      'numberposts' => -1,
      'post_type'   => 'client-dashboard',
      'meta_key'    => 'projects_$_unique_id',
      'meta_value'  => $uniqueID
    );
    
    // query
    $the_query = new WP_Query( $args );
    
    ?>
    <?php if( $the_query->have_posts() ): ?>
      <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
      <!-- NEED Sub Fields for the one repeater row here -->
    
      <?php endwhile; ?>
    <?php endif; ?>
    
    <?php wp_reset_query();  // Restore global post data stomped by the_post()
    
    ?>
  • For anyone wondering, I had to call for just that row with the following code:

      while (have_rows('projects')) {
        the_row();
        if (get_sub_field('unique_id') != $uniqueID) {
          // not our row
          continue;
        } 
        // REPEATER FIELD LOOP
        include('items.php');
      } 
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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.