Aleš Sýkora / November 28, 2023 / 0 comments

Display only first image from multi value field in toolset

Post summary: I am using a custom field called “product images” where I upload images for my custom post type Coffee machines. When I want to show the image in the archive then, I just want to display the first Image. Not all of them. What happen is that toolset field automatically display all images from the…

I am using a custom field called “product images” where I upload images for my custom post type Coffee machines. When I want to show the image in the archive then, I just want to display the first Image. Not all of them. What happen is that toolset field automatically display all images from the multi value field like this:

Backend image field has Two images inside.
Before: Toolset displays All images used in multi value image field.
After: Toolset display only first image from the field

What you need to do is add Index=”0″ to the field parameters. The index is zero-based, so the first item will be 0, the second item will be 1, the third item will be 2, and so on.

Before:

[types field='obrazek-produktu' title='%%TITLE%%' alt='%%ALT%%' align='center' size='custom' height='180' resize='proportional' separator=', '][/types]

After:

[types field='obrazek-produktu' index="0" title='%%TITLE%%' alt='%%ALT%%' align='center' size='custom' height='180' resize='proportional' separator=', '][/types]

And thats it.

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

0 comments

Share Your Thoughts