Skip Navigation

[Resolved] Pass URL parameter to target page according to filter

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

Problem: I have a custom search View that contains two front-end filters. Based on which filters have been chosen, I would like to append different URL parameters to a link's href attribute.

Solution: You can use conditional HTML blocks and the wpv-search-term shortcode to test whether or not a filter's URL parameter exists, then output different link hrefs based on those URL parameter values.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term
https://toolset.com/forums/topic/if-wpv-post-param-has-a-specific-var-then/
https://toolset.com/forums/topic/conditional-url-parameters-and-parametric-search/

This support ticket is created 4 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by pedro.S 4 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1528713

Hi,

I want to achieve exactly what Rostislav wants in this post https://toolset.com/forums/topic/pass-url-parameter-to-target-page/, but with a difference. I want that the target link to be changed dinamically according to the filter.

The view will list projects and will have 2 filters -> Year and Area

1 - So if nothing is filtered, the links will be normal without parameters
2 - if Area is filtered, the target links appear mydomain.com/projects/name-of-project?area=myarea
3 - If Year is filtered, the target links appear mydomain.com/projects/name-of-project?year=2020
4 - If both then mydomain.com/projects/name-of-project?area=myarea&year=2020

Is this possible? If custom development required i have to ask a developer but i could use some guidance of how to be achieved so that i can pass that information to him.

Thank you

#1529177

This is possible but it would be kind of complicated. First, you would need to create the custom search View that displays all the results, without URL parameters. Then you would have to implement several conditional statements in the View's loop, that test whether or not either or both URL parameters exist. We have the shortcode wpv-search-term that can be used to test if any specific URL parameter exists. Based on the results of those conditionals, you would append different text to the link URLs. Here are some documents and other tickets you can review or show your developer resource:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term
https://toolset.com/forums/topic/if-wpv-post-param-has-a-specific-var-then/
https://toolset.com/forums/topic/conditional-url-parameters-and-parametric-search/

#1530327

Thank you Christian. I will let you know if i need aditional help!