Skip Navigation

[Resolved] CAn’t get repeating field to output in a loop

This thread is resolved. Here is a description of the problem and solution.

Problem:
CAn't get repeating field to output in a loop

Solution:
Actually, we found that actually if you check the page source code, images are rendered but it's not displaying but you added the attribute to div style="display:none

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/cant-get-repeating-field-to-output-in-a-loop/#post-1298229

Relevant Documentation:
https://toolset.com/documentation/user-guides/repeating-fields/#Displaying%20Repeating%20Fields

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by ericE-4 5 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1297429
Screenshot 2019-07-22 01.46.43.png

I'm trying to build some basic HTML using all the images in a repeating image field. I've constructed my loop and content template as per the attached image. The page renders without any of the HTML.

If I remove the [wpv-for-each field="main-images"] shortcode, the HTML renders, but there's only a single image.

#1297649

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the field name as follows where we prefix the field name with wpcf-:

[wpv-for-each field="wpcf-main-images"] 
 // add your code here
[/wpv-for-each]

More info:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

#1298015
Screenshot 2019-07-22 10.51.21.png

I added the "wpcf-" prefix but it had no effect.

#1298209

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

That is strange. Can you please share problem URL where you want to display the repeating field as well as access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1298229

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked on your install and I found that actually if you check the page source code, images are rendered but its not displaying but you added the attribute to div style="display:none;" that is why its not displaying.

Further, I checked that there is the following javascript error on your browser's console:

glacier-bear-lodge:5812 Uncaught TypeError: $(...).unitegallery is not a function
    at HTMLDocument.<anonymous> (glacier-bear-lodge:5812)
    at i (jquery.js:2)

It look like its not able to reach the unitegallery script or its not loaded.

#1298283

I'm terribly embarrassed...I knew about the setting the main div to "display: none" (intentional) and the fact that the library wasn't being loaded...but I thought for sure I checked that the HTML structure for the image gallery was not being output. It was there all along though. How careless of me.

Everything's good. But can I ask you what is the purpose of the "wpcf-" prefix on the for-each loop? Why is it needed?

#1298293

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you create a custom field using Types plugin each custom field slug will have prefix as "wpcf-" but when you use Types shortcode to display the custom field, you do not have to add that:

For example:

[types field="my-number" ][/types]

Please check the following Doc:
=> https://toolset.com/documentation/user-guides/repeating-fields/#Displaying%20Repeating%20Fields

#1298309

My issue is resolved now. Thank you!