Skip Navigation

[Resolved] Repeater slug

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

Problem:

Solution:
To display the specific instance of repeating fields you can use the "index" attribut.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/repeater-slug/#post-630540

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

This support ticket is created 6 years, 8 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 2 replies, has 2 voices.

Last updated by Ljuba 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#630429

I'm using for gallery repeater. What is the slug of 'nth' images (second, third, ...), if field slug is 'gallery' (wpcf-gallery)?

Why I ask it?

In CRED I want to have 'repeater' (limited to 6), but I want to display images separately, not in gallery.

#630540

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to limit the number of images uploaded to "(wpcf-gallery)" field to 6 using CRED form?
-- If yes:
- You need to add custom javascript/jquery code to your CRED form's JS box:

jQuery(document).ready(function(){
        allowed_instances= 6;
   
        $(document).on( "click", ".js-wpt-repadd", function(e){
             // how many repetitions?
            if ( $('.wpt-repctl').length > allowed_instances-1 ) {
                // hide button to add more
                $(this).hide();
            }
        });
        // add click listener to trash buttons
        $(document).on( "click", ".js-wpt-repdelete", function(e){
   
            $(".js-wpt-repadd").show();
        });
    });
});

To display the repeating fields you can use the index attribute:
More info:
=> https://toolset.com/documentation/user-guides/repeating-fields/#Index%20parameter%20Repeating%20Fields

#630657

Answer was second ("Index: Displaying a single value for a repeating field") and it works. Thanks.