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
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?
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.
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:
Please let me know if you have questions about this and I can offer more guidance.
Hi Christian
We tried ini_set('pcre.jit', false); and it worked! Thank you so much.
Alex