Skip Navigation

[Resolved] How do I limit the number of images presented by a repeater image field?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Shane 7 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#534497

I am trying to: limite the number of images shown by a repeater image field

I visited this URL: https://toolset.com/forums/topic/image-field-delete/

I expected to see:

Instead, I got:

One of the last topic I opened was about a repeater image field. The template part code to show the image data on frontend is here: hidden link How can I limit the number of images in the frontend to 4?

Thanks.

Álvaro

#534798

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alvaro,

Thanks for contacting us again 🙂

Lets see you can actually do this by limiting the amount of loops and breaking it once it reaches the desired iteration.

Take a look at this code below.

$Count = 0;
foreach($Array as $Key => $Value){
    //your code

    $Count++;
    if ($Count == 4){
        break; //stop foreach loop after 4th loop
    }
}

Create a count variable to hold the current position in the loop and then break the loop when the number of iteration is achieved.

Thanks,
Shane

The forum ‘Types Community Support’ is closed to new topics and replies.