Support

Account

Home Forums Add-ons Repeater Field Showing ONLY repeater rows that contain a certain keyword Reply To: Showing ONLY repeater rows that contain a certain keyword

  • Hi James @acf-support,

    I can’t seem to get my search query to work for repeater rows. This looked like the solution but I feel stuck.

    I have a search results page that should show all regular posts and a repeater from within a custom post type. The CPT is ‘troubleshooting’ and inside each post from this CPT there is a repeater (ts_article) which has a ‘title’ and ‘content’. The results page should show the regular posts as well as the repeater rows that have the search query in it.

    Here’s a sample code of when a custom post type (troubleshooting) is found.

    <?php } elseif ($type == 'troubleshooting') { ?>
    <?php if( have_rows('ts_article') ): ?>
    <?php while ( have_rows('ts_article') ) : the_row(); ?>
    <!-- article -->
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
      <div class="results-list">
    
        <a href="<?php the_permalink(); ?>">
          <p class="result-category">
            <?php $cats=get_the_category(); ?>
            <?php echo $cats[0]->cat_name; ?> - <?php the_title(); ?>
          </p>
          <h3><?php echo the_sub_field('title'); ?></h3>
          <?php if( get_sub_field('content') ): ?>
          <div class="result-excerpt">
            <?php echo custom_field_excerpt(); ?>
          </div>
          <?php endif; ?>
        </a>
    
      </div>
    
    </article>
    <!-- /article -->
    <?php endwhile; ?>
    <?php endif; ?>
    <?php } ?>