Skip Navigation

[Resolved] Can only add up to 8 images in for each loop for the conditional to work

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

Problem: I have a conditional set up that tests whether or not a repeating custom image field has any value(s). It works well up to 8 repetitions of the image field. If I have 9 or more repetitions, the conditional breaks.

Solution:
Disable the pcre.jit regex engine on the server by adding this line to your wp-config.php file:

ini_set ( 'pcre.jit' , false);

Relevant Documentation:
https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 7 replies, has 3 voices.

Last updated by davidR-12 4 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1515127

hidden link

I am using a conditional to display the second tab of images if there are images to be displayed. On this page, there are images to be displayed but the conditional is not working. You can see an example of a working page here with 2 tabs:

hidden link

It works for upto 8 images and then adding a 9th the second tab disappears.

This is the code I am using :

[wpv-conditional if="( $(wpcf-exhibitions-selected-works-images) ne '' )"]
  [restab title="SELECTED WORKS"]
<div id="my-slider" class="royalSlider rsDefault">[wpv-for-each field="wpcf-exhibitions-selected-works-images"]<a href="[types field='exhibitions-selected-works-images' size='full' url='true' separator=''][/types]">
  
      [types field='exhibitions-selected-works-images' alt='%%ALT%%' title='%%TITLE%%' size='full' align='none' class='rsImg' separator=''][/types]

  
  </a> [/wpv-for-each]</div>
[/restab]
  [/wpv-conditional]

If I remove the conditional then the second tab appears.

#1516405

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Please allow me to check this - I will check this issue first thing tomorrow.

#1516459

Thank you Minesh. When is tomorrow for you (How many hours)? I have a client waiting on this and its a prominent and live site.

Regards,

David

#1516539

Hello, Minesh asked me to take a look since he's in an earlier time zone. I hope that's okay. I don't see anything obvious in the template that would cause the conditional to fail after 8 images. Do you have a staging environment set up where I can turn plugins on and off and add markup to try to pin down the problem?

#1516667

Hi Christian,

I don't have a staging site for this site. Can I send you a Duplicator zip?

David

#1516701

Yes that would be fine. In this case since the images are integral to the issue, please include the uploads directory, or at least the images required for the two posts you mentioned in the link above. Normally I would ask to strip out uploads to save space, but in this case I think you should include them if possible.

Private reply field here for posting a Duplicator download link. Thanks!

#1516821
#1518991
Screen Shot 2020-02-20 at 10.54.32 AM.jpg
Screen Shot 2020-02-20 at 10.54.21 AM.jpg

Okay it's odd because on my local installation the conditional works without any problems when I have 9 images. Is there any server-side caching system in place, like object caching, memcached, etc? Is it possible to purge any of those server-side caches?

I've seen some strange issues with conditionals as described in this erratum: https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/
Can you try disabling pcre.jit in your wp-config file?

 ini_set ( 'pcre.jit' , false);
#1523727

Hi Christian,

Thank you, that snippet of code worked perfectly.

Regards,

David