Skip Navigation

[Resolved] Content template showing shortcodes when audio player used

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

Problem: Shortcodes are displayed on the front-end of the site instead of being rendered, when used in complex or long conditionals.

Solution: There is a known issue with complex and long conditional content in certain versions of PHP, related to regex parsing by WordPress.
One possible solution is to try adding the following information to your wp-config.php file:

ini_set('pcre.jit', false);

Another option is to ask your host to add this to your php.ini file:

pcre.jit = 0

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

This support ticket is created 5 years, 1 month 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 4 replies, has 2 voices.

Last updated by Alex W 5 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#1449117
Screenshot 2020-01-09 at 16.32.09.png

I have a content template for a post type that gets some values from custom fields on another page. I am getting these like this:

[types field='audio-title' item='2242'][/types]
[types field='audio-file' item='2242'][/types]

It works fine, apart from on pages where there is an audio player (I use the Toolset one). Then something odd happens and all shortcodes are exposed on the frontend (see image). All subsequent Toolset shortcodes are also exposed. It's like they aren't working at all.

What is odd is that it works locally for me, but not on the dev server. Both are running PHP7, Types 3.3.8, Views 3.0.2

Any ideas what might be happening? The only other plugins installed is the Classic Editor.

Thanks

Alex

#1449133

Just worked out that it's a conditional breaking things. Here is the whole code:

[wpv-conditional if="( '[types field='audio-file' item='2242' raw='true'][/types]' ne '' )"]
    <div class="audio">
      <hr>
      <h5 class="h4 audio-title">[types field='audio-title' item='2242'][/types]</h5>
      [types field='audio-file' item='2242'][/types]
    </div>
    [/wpv-conditional]

I only want to show the 'audio' div if the 'audio-file' field has some content. If I remove this conditional it fixes things, but I would rather be able to use the conditional. Any ideas why it's breaking things?

#1449183
Screenshot 2020-01-09 at 17.15.45.png

Another update:

Although removing the conditional got the audio custom fields to display, there are still broken shortcodes further down the page. See screenshot.
I also tried removing the audio custom field, but it didn't fix things.

#1449475

Hello, I don't think the issue is specifically related to the audio file or audio player. There is a known issue with certain versions of PHP where conditionals with a lot of content are causing problems with shortcodes, and I suspect this is what you are experiencing: https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/

You can try asking your host to update to a higher version of PHP 7, but that is not always possible. The most reliable solution in this case is to break up conditional content into several separate templates. Another solution is to try adding the following information to your wp-config.php file:

ini_set('pcre.jit', false);

Another option is to ask your host to add this to your php.ini file:

pcre.jit = 0

Please let me know if you have questions about this and I can offer more guidance.

#1450331

Hi Christian

We tried ini_set('pcre.jit', false); and it worked! Thank you so much.

Alex