Struggling with Loopers

Hello guys!

I’m here once more because I’m struggling again with loopers and ACF Pro. The fields that I’m having a hard time pulling data from repeaters and repeaters inside repeaters. I’ve watched all the videos about Looper on Themeco YouTube channel. Tried a lot to make it work, but could not. And I don’t feel it’s that hard that I couldn’t figure it out, but I did not. I feel kind of dumb for that. In my local Wordpress dev server, I have Twig enabled on my X Pro Theme, so I use its syntax on my client I do not because of the PHP version.


Note that I’m not using singular names for child fields of a main group like destination_name, trip_price … They belong to a father group that has singular names like pantanal_details_group, amazonia_details_group and so on.

I’ve tried things like

{{ looper.field({“key”:“school_mandatory_documents.0.nome_da_escola.0.documentos_obrigatorios.0.titulo_documento”}) }}

{{ looper.field({“key”:“school_mandatory_documents.nome_da_escola.documentos_obrigatorios.titulo_documento”}) }}

I’m trying for 4 days with no success. I’m coming here for help. Will give you access info in private

The link I was testing is https://clientes.edgardmello.com/pantanal-docs/

Hello @edgardmello,

Thanks for writing in! You have not translated the ACF plugin. Therefore, your should be using this:
{{ looper.field({"key":"school_mandatory_documents.0.documentos_obrigatorios.0.arquivo_documento.title"}) }}

You can check the demo in the URL I added in the secure note below.

Cheers.

Hi @ruenel

Thank you for your reply. The example you provided didn’t exactly achieve what I needed. I have edited your example and tried to explain my requirements a bit further.

My goal is to list all the data in the array. For example, if I have 4 contract entries, it should loop through all 4 contracts and display them on the looper consumer. If I’m using a button, it should create 4 buttons, and so on.

Regarding the school mandatory documents section, as it has a repeater inside a repeater, I believe we should use a different provider for the inner repeater, separate from the main (parent) group that contains all fields. Is that correct?

Hello @edgardmello,

What you are missing is the second loop. They should be nested like this:

Div - Looper Provider (`school_mandatory_documents`)
   Div - Looper Consumer
        Headline Title (`noma_da_escola`)

        Div - Looper Provider (`documentos_obrigatorios `)
             Div - Looper Consumer
                   Headline Title (`titulo_documento`)
                   Filename Text (`{{ looper.field({"key":"arquivo_documento.title"}) }}`)
       

I have indented them to demonstrate the element structure.

Hope this makes sense.

Tnks for replying again.

I’m currently trying to figure out which types of provider and looper consumer I should be using.

For the provider, I’ve attempted to use both ACF Post Field and Option Field. When using the ACF Option Field provider with the main group destination_details, I am able to use the debugger and see all the data available for consumption.

However, if I use school_mandatory_documents as a provider, for example, and set the provider type to ‘dynamic content’, I cannot see any data available for consumption.

For consuming the data, I consistently use the ‘Looper Field’ type.

I have also translated all the field names into English to make them easier for you to understand.

Hello @edgardmello,

Your second looper should be this:

Please check out the demo I have created in the secure note below.

Thanks.