Skip Navigation

[Resolved] Popup content not looping through custom fields

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

Problem:
Client is using a Content Template to generate the HTML required to work with the "thickbox" lightbox but popups are all showing the content of the first result in the Loop.

Solution:
The same id was being used for all of the target DIVs and the href links to open them. Using the shortcode to append the post-id field to the id ensured unique ids on each iteration of the Loop.

Relevant Documentation:
https://toolset.com/documentation/woocommerce-views-shortcodes/

This support ticket is created 7 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Timothy 7 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#396231

I'm using a content template to output some Views. All is well except in the Partner section of this page, I'm using a popup (thickbox) to output image/text custom fields but it's not looping through these, it's only showing the first image/text for each popup:

hidden link

This is the code I'm using:

 <div class="partner-member-image"> 
    <a href="#TB_inline?height=500&width=750&inlineId=PartnerPopup"  class="thickbox">
      [types field="partner-image" alt="[types field='partner-name'][/types]" size="full" align="center"][/types]
    </a> 
</div>

<div class="partner-member-name"> 
      [types field="partner-website" title='[types field="partner-name"][/types]' target="_blank"][/types] 
</div>

<div id="PartnerPopup" style="display:none;">
     <img src="[types field='partner-image' size='full' url='true' align='center'][/types]" /> 
     [types field="partner-name"][/types] <br/>
     [types field="partner-description"][/types] 
</div>

Thanks for your Assistance,

Tim

#396442

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Looking at the generated HTML on that page the contents of your pop-up divs are being correctly generated.

Your problem is that you have assigned the same id ("PartnerPopup") to each of them—if the same id appears more than once on the page only the first one will ever be selected—and the link you generate always points to that same id.

You need to adjust your link and the id to something unique each time. You could simply append the partner-name field, which you are already using.

#396493

Great solution. Actually, partner-name didn't work as the names have spaces which created invalid URLs, so I used the post-id field, which worked perfectly. Thanks so much!

BTW, you guys have really terrific support!

Tim

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