Skip Navigation

[Resolved] Conditional output based on url query param

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

Problem:
How to use values from URL parameters as conditions in wpv-conditional shortcode?

Solution:
The shortcode wpv-search-term can be used to output the value of any URL parameter specified with the urlparameter shortcode attribute.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term

This support ticket is created 6 years, 9 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.

Our next available supporter will start replying to tickets in about 1.86 hours from now. Thank you for your understanding.

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)

This topic contains 2 replies, has 2 voices.

Last updated by kirillS-3 6 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#617224

I want to make a conditional output, based on url query param. So, if URL of page like this:
hidden link
then I want to show some content if ABS param is speciafied or not specified or it is exactly 152

I try to make it like this:

[wpv-conditional if="(get_query_var( 'abs', 0 ) eq '0' )" ]

<p class="special">ABS is not set</p>

[/wpv-conditional]

but it always show "ABS is not set" on page, not depend on 'abs' param is really set in URL or not.

#617341

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi there

Did you register the function get_query_var to be able to use it inside conditional shortcodes at Toolset > Settings > Front-end Content?

You could also try using the Views shortcode wpv-search-term with the param attribute set to abs, which would output the value of a URL parameter 'abs'. (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term)

If that doesn't help let me know and I can investigate further.

#617969

Hi Nigel,

Yes, I registered this function. And it is still doesn't work.

But wpv-search-term works well, so problem solved.