Skip Navigation

[Resolved] 2 issues: add class according to url param, and retrieve url param to link

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

Problem:
How to retrieve URL parameters so that they can be used in templates.

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

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

This support ticket is created 6 years, 10 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
- 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 Ido Angel 6 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#618243

hey,

so:

1. i have a post type "articles" with taxonomy "subjects". i have a link which filters out search results. it's a long story why i need that (instead of just placing a search filter) but that's what i need now. the link goes like this:

<a href="<em><u>hidden link</u></em> param='wpv_post_search']&wpv-subjects=[wpv-post-taxonomy type='subjects' format='name']&wpv-post-type=articles">articles</a>

the wpv-post-search works. it takes the term already searched for in the page url (with text search).
the wpv-post-type works - because there i have a specific term.
but the wpv-subjects - DOESN'T work :\ i thought it would somehow take the url-param from the existing url, but it doesn't.

is there any way i can some how force this?
basically what i need is to retrieve the entire url to the link (hidden link), and just add "&wpv-post-type=articles" in the end.

2. every time i press this link, i want to it have a different style to show that this is the active link. is there a way to add a class to the link which has the same name as the url-param of (for example) wpv-subjects=yyy?

thanks!
Ido

#618584

Nigel
Supporter

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

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

Hi Ido

Just scanning your question it seems like you would want to use wpv-search-term shortcode (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term).

Although it is described in the context of outputting the value of the parameter used for WordPress searches (e.g. 's') you can use it output the value of any URL parameter on the page, just by specifying what the URL parameter is called. And you can use it multiple times to retrieve different parameters when there is more than one.

For your second question, I'm not sure I understand.

When you press the link you leave the page, so why are you trying to style a link on a page you just left?

It no doubt makes sense to you, and you might want to use the same technique (wpv-search-term) to add a class to the anchor tag.

#618595

thx! got this resolved 🙂