Skip Navigation

[Gelöst] Elementor Pro shortcodes in Content Templates – and Conditionals

This support ticket is created vor 6 Jahren, 2 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Nigel vor 6 Jahren, 2 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1115469

Ok - another fun question.

Id like to render an Elementor Template shortcode inside a conditional

Id use a Content Template shortcode in Elementor - within a Shortcode Element on the front end like this

[wpv-post-body view_template="footer-select"] <-- in a shortcode element block

Inside this content template I would like to set a conditional that works on a custom field value - if custom field = "AU" show: Elementor AU footer shortcode, If custom field = "Us" = Elementor US Footer shortcode.

Whats inside the Content Template above looks like this:

[wpv-conditional if="( $(wpcf-country-content) eq 'us' )"]
INTERNATIONAL AND US Country Content FOOTER
[elementor-template id="51067"] <-- this is the USA Elementor Footer
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-country-content) eq 'au' )"]
Australian Country Content FOOTER
[elementor-template id="666666"] <-- this is the Australian Elementor Footer
[/wpv-conditional]

-----

Now this works and renders the TEXT only and not the actual shortcode for the Element template.

What am I doing wrong?

#1116127

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

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

Screen Shot 2018-09-27 at 07.23.51.png

Hi Stuart

What happens if you insert the template shortcodes within conditionals directly on the page rather than in a Views content template?

There doesn't seem to be anything intrinsically preventing this from working.

I inserted a footer template directly on a page using conditionals like so:

 <h1>Here comes the footer template</h1>
[elementor-template id="54"]
<h1>That was the footer template</h1>

[wpv-conditional if="( '[wpv-post-slug]' eq 'testing-elementor-template-shortcodes' )"]
<h1>And here it is again</h1>
[elementor-template id="54"]
[/wpv-conditional]

You can see the results in the screenshot, where I have a custom header, the footer appears twice inside my content area from the above code, and then I have the custom footer itself.

Which is intended to highlight that inserting the footer shortcode in this way implies inserting it in the content area, not in the footer.

(I don't know how Elementor controls the display of the custom footer itself under the hood. I suspect the right way to switch footer would be via some API hook where you can test the value of the custom field for the page you are on and alter it accordingly, but you would need to consult with them about how that might work.)