Skip Navigation

[Gelöst] How to check if the gallery image in foreach loop is also the property image

This support ticket is created vor 7 Jahre, 5 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 4 Antworten, has 2 Stimmen.

Last updated by zoeS vor 7 Jahre, 5 Monate.

Assisted by: Shane.

Author
Artikel
#448918

Hi, I'm creating a real estate site using your Real Estate reference site. On the single-house content template, for horribly complicated reasons, I need to display the property photo followed by all of the gallery photos, excluding the one that is the same as the property photo – basically I don't want it to display twice. Is there any way to query the gallery photos before displaying them to find out if they are the same image as the property photo? The property photo will not always be the first in the gallery list unfortunately. Below is my current output:

[types field="property-photo" width="900" height="600" align="none" resize="pad" padding_color="#f9f7f3"][/types]
[wpv-for-each field="wpcf-property-gallery"]
      [types field="property-gallery" width="900" height="600" align="none" resize="pad" padding_color="#f9f7f3" separator=", "][/types]
[/wpv-for-each]

Many thanks!

#448920

Shane
Supporter

Languages: Englisch (English )

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

Hi Zoe,

Thank you for contacting our support forum.

Is there an index where you will always upload the property photo ?

Because you can always add a separate field to hold the property photo.

Looking forward to hearing from you soon.

Thanks,
Shane

#448923

Hi Shane

I am using the exact setup for images that comes with the Real Estate reference site, so the property photo is already in a separate field (property-photo), but the same image exists also in the gallery array. What I want to do is filter it out of the gallery array before displaying it in this view. Not adding it to the gallery in the first place is not an option unfortunately, for complicated reasons.

#448940

Shane
Supporter

Languages: Englisch (English )

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

Hi Zoe,

What I'm thinking that you can do is to use a wpv-conditional code check to see if the urls are the same.

If they are the not same then the code should display images like normal. Have a look at the link below.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

Please let me know if this helps.

Thanks,
Shane

#449440

Thank you! I got it working eventually using the wpv-post-field shortcode in the conditional statement.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.