Display all repeater subfield values from DB


Here is the thing – I’m working on a personal project which includes multiple custom fields (created via ACF). Few of them are repeater types.

What I want to achieve is to display 3 arrays/blocks of those repeater subfield values. For better understanding, I have this repeater field: open_workshops, and this field includes subfields: date, location, partnerships.

I want simply to show all values from those subfields stored in DB. Something like:

Open Workshops:

  • Date: Jan 2017, Feb 2017…Dec 2019 etc

  • Location: New York, Warsaw…

  • Partnerships: EY, Google..

What issues I’ve noticed – first of all, because of field type (repeater) it’s damn hard to find those values in the DB. Because its not a single field but ACF replicates their names, so instead of looking for single field: open_workshops_date i need somehow to find: open_workshops_0_date, open_workshops_1_date etc.

My initial code was:

  if( have_rows('open_workshops') ):
        while ( have_rows('open_workshops') ) : the_row();
            $sub_value_1 = get_sub_field('date');
        $sub_value_2 = get_sub_field('location');
        $sub_value_3 = get_sub_field('partnerships');

          echo '$sub_value_1';
echo '$sub_value_2';
echo '$sub_value_3';

    else :
        // no rows found

I’ve tried as well the suggestion from this post:
Retrieving all data from repeater fields

but it shows nothing.

, , Pawel Skaba 1 year 0 Answers 94 views 0

Leave an answer