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
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
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?
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?
Yes, it's absolutely clear now, thank you. Marking resolved.