Skip Navigation

[Resolved] Script tag in conditional in Layouts

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

Problem: I would like to place a script tag in a conditional in a Layouts visual editor cell.

Solution: Enqueue the script properly in a child theme or place the script tag in a Content Template, then insert the Content Template in the Layout.

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

Last updated by martinH-10 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1088390
visual cell.png
dissapered.png

I am trying to: Display embeded form with script if conditions are met with Layouts.

[wpv-conditional if="( $(wpcf-vyber-balicku-lekci) eq '15x50' ) AND ( $(wpcf-vyber-lektora) eq 'czech' )"]<script type="text/javascript" src="hidden link"></script>[/wpv-conditional]

But when I save the Visual editor cell, script dissapears.

#1088674

Inline script tags aren't allowed, in general, in any Layouts cell editors. The best way to add a script tag is to enqueue it in your theme using WordPress's enqueue_scripts method:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts

If you're not a developer, a simpler way is to add the script tag to a Content Template, then insert the Content Template in your Layout.

#1089257

Thank you Christian, the content template was best idea. Works like a charm.