Skip Navigation

[Resolved] Return # of images rather than posts (repeatable)

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.

This topic contains 3 replies, has 2 voices.

Last updated by jasonw-2 1 year ago.

Assigned support staff: Luo Yang.

Author
Posts
#1792281

Hi there!!!

I have a CPT where my client can upload images to show in a gallery. I have a repeating image field and a post form for them to upload said images. I am trying to limit the number of images shown in the gallery to 18 but I'm pretty sure I just realized that my view setting of "Display 18" is displaying 18 posts worth of images. So if there are more than 1 image (using the repeating field) per post then it's showing the 18 actual posts (worth of images) instead of 18 images in whole.

I'm using this for the loop:
[wpv-for-each field='wpcf-inmanimages']
<a href="[types field='inmanimages' size='full' url='true'][/types]">[types field='inmanimages' width='150' height='150' align='none' resize='crop'][/types]</a>
[/wpv-for-each]

and a blocks content template attached to the view being output into an Elementor page. Seems to work fine with the exception stated above.

I've spent a couple hours in here trying to find a solution.

Also: I am going to want to display all with pagination on a different gallery page, so please let me know if I need to keep that in mind with whatever solution we end up with.

As always, thanks so much!!!

Jason

#1792741

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

I assume we are talking about a post view:
- Query your custom posts
- In view's loop, you are displaying the repeating image field with the codes you mentioned above.

If it is, then it is expected result:
So if there are more than 1 image (using the repeating field) per post then it's showing the 18 actual posts (worth of images) instead of 18 images in whole.

The post view can only setup limitation on posts, it can not setup limitation on repeating image field.

You might consider other workaround, for example:
Display only one image for each post, replace the codes you mentioned above as below:

[wpv-for-each field='wpcf-inmanimages' start="1" end="1"]
<a href="[types field='inmanimages' size='full' url='true'][/types]">[types field='inmanimages' width='150' height='150' align='none' resize='crop'][/types]</a>
[/wpv-for-each]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153482

#1793567

Thanks, Luo.

I think it would be easier to just change the repeating field to a single image. *Far less confusing for the client.

Thank you for trying to help!!

#1793569

My issue is resolved now. Thank you!