Skip Navigation

[Resolved] Toolset shortcodes not rendering inside of data-target=""

This support ticket is created 7 years, 2 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by damianS-2 7 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#483139

I am trying to: Use a Toolset shortcode inside of am <a tag, like this:
<a data-target=".[types field='first-name'][/types]-[types field='last-name'][/types]"></a>

To get this output:

<a data-target=".Test-User"></a>

Instead, I got:

<a data-target=".[types field='first-name'][/types]-[types field='last-name'][/types]"></a>

Is this just a type of attribute that will not render Toolset shortcodes?

Thanks,

Damian

#483206

ShortCodes should NOT be used in an HTML attribute by definition.
This is practically not accepted by WordPress:
https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/

It is possible in Views and if you use Views Plugin because we created some magic parser that is coded in the Views Plugin (wpv_do_shortcode())

And if you have Views active that works fine, I tested it locally with some Fields I have setup:

<a data-target=".[types field='number' output='raw'][/types]-[types field='test-select' output='raw'][/types]">HERE</a>

Produces this HTML:

<a data-target=".1.3-1">HERE</a>

(1.3 and 1 are my field's values)

You need also to ensure a raw output as otherwise some HTML can get along with the ShortCode and break your output

#483356

This is great info, thanks.

So it sounds like you are saying that I can use Toolset short codes within HTML attributes, as long as I do it within the Views plugin before it is rendered to a WordPress field, like Excerpt. Is that right?

#483526

No, that is not what I mean.

I mean, ShortCodes in HTML attributes are NOT supported and one could even say, forbidden by WordPress itself.

Views does provide a solution for this mainly because it was possible in past (with WordPress) and Toolset relies on ShortCodes and all the "games" you can play with them.

When WordPress updated the ShortCode API last year, thousands of sites where broke due to that (unannounced!) massive update.

We provided our own parser to solve that, and that parser is coded in Views, so it will work only if Views is present on Site and active.
It will NOT solve issues of 3rd Party ShortCodes as well, it will address only Toolset ShortCodes.

But, as example, in a Excerpt, this will not work, for the simple reason that Excerpts are even more restricted from WordPress side.
Basically any HTML will be stripped, ShortCodes not parsed at all.

ShortCodes should be used in a WYSIWYG (Post body or similar)

Does that clarify the issue?

#483837

Yes, it's absolutely clear now, thank you. Marking resolved.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.