How to use ACF repeater with Pinegrow?

Hi there ,
I asked a while back if anyone knew how to use the ACF repeater in the gutenberg blocks but i did not get a answer so i’m trying again.

Have tried a lot of time to get this working but i just can’t get it working.
Not sure what to use in pinegrow to select the element that needs to be repeated.

The most logical way would be to select the element in my case a col-md-4 and add post field with a id.

Then the id is used in ACF as field name on the repeater and adding some more post fields on the content such as title and description and giving them a id and using the title and description id in the repeater.

However this does not work for me i only get a text with Array in wordpress.

This as been bugging me for a long time now and it would be nice to get a answer if it’s even possible to use ACF repeater in combination with blocks in pinegrow with the current actions.

Hey @beatngu,
Can you give me a little more detail on what you are trying to achieve at the end? Somehow this isn’t quite clicking in my mind. Are you accessing an existing repeater field on the front-end, or …
Thanks,
Bob

Take a look at my answer in this thread. I think it’s exactly what you are looking for.

ACF repeater fields in Gutenberg blocks - Blocks - Pinegrow Community Forum

Thanks Roel!
Not was i was hoping for but i guess this is better then nothing , wish pinegrow had better implementation.

I must be doing something wrong with your solution , managed to repeat the columns but the content is not repeated with the text i enter in the gutenberg fields.

On the title and description in my column i added a post field for the title and one for the description or do i need to do something else?

Was following this ACF | Repeater (advancedcustomfields.com)

And i thought i could just handle the get_sub_field with a post field action from pinegrow but i may be wrong.

Maybe better to include the code on how it currently looks

<?php if( have_rows('page_services_block') ):while( have_rows('page_services_block') ) : the_row(); ?>
<div class="col-md-4" data-aos="fade-up" data-aos-delay="0">
    <div class="service service-style-2">
        <i class="fas fa-laptop-code text-primary"></i>
        <h5 class="service-title"><?php echo get_field( 'page_service_title' ); ?></h5>
        <span class="service-text"><?php echo get_field( 'page_service_desc' ); ?></span>
    </div>
</div>
<?php endwhile; else : endif; ?>

As you can see in the code, the post field action you used is implementing “get_field”. This will not work within a repeater. As you pointed out yourself you’ll need to use “get_sub_field” and as far as I know the only way to do that is to use a PHP code action and write the whole echo manually (you can use the checkbox but in the below example I opted not to…).

Like this:

image

ps: to be complete: the code inside the field in the above image looks like this:
echo get_sub_field(‘subheading’);

1 Like

Hi Bob,
I am making a site modular with just gutenberg blocks so my clients can edit them easily.
Have a section with 6 columns with a icon , title and description and i want to use the ACF repeater.

If it’s always just going to be 6 columns i could just make 6 editable columns in the block editor.
However if my clients want to add more columns they can’t because it’s fixed at 6 columns and with a repeater you can add as many as you want.

Say you have a section with team members and you have 6 members to start with but after a while you hire another 3 members.I would then need to update the site for my client because it’s a fixed set of columns without the repeater but if i do it with the repeater my client can just click add row in the repeater and i do not need to do anything.

Thanks for trying to help Roel.
Awesome Roel i got it working :slight_smile:

1 Like

No problem, happy to help!

@Roel @beatngu Because not all situations can be easily handled (only) with standard smart actions, we cover the special cases of WordPress development in this chapter of our dedicated WordPress FAQ:

It requires a little more investment and understanding of how WordPress and PHP work, but it is well worth it to integrate complex features.

At the end of the story, everything is possible :slight_smile:

It would be awesome to get more information in that wordpress section about more things that’s not possible out of the box with pinegrow and how to solve them with extra php and such.

I am a .net developer and not a php developer and i was very close with getting this to work with the php action in pinegrow with having a look at the documentation on ACF about the repeater but i messed up with the formatting of the code that goes in to the php code action in pinegrow.

I certainly have no problem with looking at documentation about various things but i feel pinegrow could use some more use examples on certain wordpress actions.

What i am saying i can see what the various of php code does but my main problem is how to use them in pinegrow so i think it would help a lot of users to see how it it’s added in pinegrow so they can just copy past wordpress php code from various of places.

Also i want to ask this , is it possible to add the making of block patterns in pinegrow without the use of ACF?

I have looked at the documentation of the block api and with a quick look it looks like it’s working a bit like custom posts. Block Patterns | Block Editor Handbook | WordPress Developer Resources

@beatngu Message heard.

Long before the arrival of smart actions with ACF support, I had written this document which is still a good inspiration for understanding what is possible with Pinegrow: How to use ACF Pro Flexible Content with Pinegrow WP - Pinegrow Web Editor - Documentation and Tutorials

3 Likes