Skip Navigation

[Resolved] How to get attribute value from content template shortcode in conditional

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

Problem:

The issue here is that the user is using the [wpv-post-body view_template="my-template" lazyload="no"] to pass the attribute lazyload = 'no' and then retrieve it in the template using [wpv-attribute name="lazyload"]

strong>Solution:

Unfortunately this is not possible as lazyload='no' is not a valid attribute as well as you're not able to retrieve it using [wpv-attribute name="lazyload"] as this only works for views shortcode attributes.

This support ticket is created 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by roulartaM 5 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1319171

Hi there!

I have this content template shortcode that I've implemented in a toolset view:

[wpv-post-body view_template="my-template" lazyload="no"]

I try to get the value of the "my-template" parameter in a conditional in my content template but I didn't find out how to do.
This is what I've tried:

TRY 1: [wpv-conditional if="('[wpv-search-term param="lazyload"]' eq 'no')"]geen lazy load a.u.b.[/wpv-conditional]
TRY 2: [wpv-conditional if="('[wpv-search-term param="lazyload"]' eq 'yes')"]lazy load a.u.b.[/wpv-conditional]
TRY 3: [wpv-conditional if="([wpv-search-term param="lazyload"] eq 'no')"]geen lazy load a.u.b.[/wpv-conditional]
TRY 4: [wpv-conditional if="([wpv-search-term param="lazyload"] eq 'yes')"]lazy load a.u.b.[/wpv-conditional]
TRY 5: [wpv-conditional if="([wpv-attribute name="lazyload"] eq 'no')"]geen lazy load a.u.b.[/wpv-conditional]
TRY 6: [wpv-conditional if="([wpv-attribute name="lazyload"] eq 'yes')"]lazy load a.u.b.[/wpv-conditional]
TRY 7: [wpv-conditional if="([wpv-attribute name='lazyload'] eq 'no')"]geen lazy load a.u.b.[/wpv-conditional]
TRY 8: [wpv-conditional if="([wpv-attribute name='lazyload'] eq 'yes')"]lazy load a.u.b.[/wpv-conditional]
TRY 9: [wpv-conditional if="([wpv-attribute param='lazyload'] eq 'no')"]geen lazy load a.u.b.[/wpv-conditional]
TRY 10: [wpv-conditional if="([wpv-attribute param='lazyload'] eq 'yes')"]lazy load a.u.b.[/wpv-conditional]

What should I do to make it work please? 🙂

#1319209

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for getting in touch.

Actually based on our documentation, none of these shortcodes will work for your case.

There isn't a way to get that attribute. The lazyload attribute is actually not a valid attribute of the [wpv-post-body] shortcode. Unlike our views shortcode this shortcode does not support custom attributes.

So there isn't a way to actually get this attribute value that you are passing.

Thanks,
Shane

#1320835

My issue is resolved now. Thank you!