Support

Account

Forum Replies Created

  • Thanks for the help James @acf-support! I’ll see if I can take it from here! Cheers!

  • Hi James @acf-support,

    Great! Nearly there. How do I go about including both the Title and Content sub fields in the SQL? The example only shows for one sub field.

    "
    SELECT * 
    FROM {$wpdb->prefix}postmeta
    WHERE meta_key LIKE %s
    AND meta_value = %s
    ",
    'images_%_type', // meta_name: $ParentName_$RowNumber_$ChildName
    'type_3' // meta_value: 'type_3' for example
  • Hi James @acf-support,

    I was asking more along the lines of modifying the WP Search Query to search through repeater fields. Your solution above doesn’t show any results because the WP search query, by default, only looks at the title and content of a post. I am using SearchWP which allows to index custom fields, but repeater fields each need to be declared separately for indexing (please see attachment). This is pretty counter intuitive, as there is a chance that the repeater increment can be beyond what is declared.

    Also, the results count is still considered as 1 (ONE) according to WP even if the query appears in multiple repeaters in ONE post.

    I found this code (i haven’t tested yet) but it seems to only be for regular custom fields, not repeater fields. Do you think you can modify it to include repeaters?

    https://gist.github.com/charleslouis/5924863

    Thanks.

  • 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 } ?>
Viewing 4 posts - 1 through 4 (of 4 total)