Skip Navigation

[Resolved] Pass an URL parameter to a View

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

Problem

How can I pass an URL parameter to a Search, so that when a user clicks on a Link on page A, he is directed to Page B with a View, where a Custom Search (by URL parameter) should take the passed Parameter and present filtered results?

Solution

Create the View as usual and add a Custom Search by URL parameter.
Save the parameter for later usage.

Wherever you link to the page where the View is inserted to, please edit that Link and add the URL parameter to match the desired Search term.
An example:


http://site.com/page-with-view/?url-parameter-set-in-view=value_to_search

Please adapt the "?url-parameter-set-in-view=value_to_search" part.
"url-parameter-set-in-view" will be the URL parameter as seen in the View Query Filter Settings, and "value_to_search" is the exact term to search by when clicking that link.

This support ticket is created 6 years, 7 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Beda 6 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#625674
capture.jpg

Hello,
I created a view with a category filter with radio buttons.
the default label is "tous", is there a solution so that it is not the default label that is select on loading page but the label "actif" as in the screenshot (in red) ? And is there a solution for change de dsiplay order of the label, i want to display the default label in second postion, after label 'actif' ?
Thanks for your collaboration.

Olivier Foguenne

#625837
Bildschirmfoto 2018-03-17 um 08.32.20.png

In Toolset Custom Searches, you can manipulate exactly only what you see in the GUI "New Filter" or "Edit Filter".

Hence, if there are sort options, you can use them, but only them (unless you apply some sort of Custom Code).
If there are default value settings, you can use them as well, but only them (unless you apply custom code).

For each field type, the settings are a little different, although we try to unify them as much as possible.

Now, for Radio Fields, if you open the "New Filter" or "Edit Filter" GUI, you have the option to "use existing field values", or manually entered values.
If you choose manually entered values you can re-order the values as you like.
If you choose existing values, things will be less controllable.

You can label the first default option as you like, and if you do it with the manual values, you will be able to have the sequence you like.
Moreover, you have asc/desc (this is alphabetical) ordering, in the Filter.

I attached a screenshot of the possibilities.

#626555
capture.jpg

Hi Beda,

I don't have the same presentation as you (see the screenshot).
Moreover, when I sort, I lose alphabetical sorting by post titles. What should I do to keep ordering alphabetic posts ?
Thanks for your help

Olivier

#626561

You mentioned you want radio buttons but now it seems you want drop-down fields?
Moreover, I do not think that is a Custom Field.
It rather seems a taxonomy?

There you cannot use that feature, as it exists not for taxonomies but only fields.

I think you will need to change the setup and use a Custom Field instead of a Taxonomy, if you require the custom values feature.

#626570
capture.jpg

Yes, it is custom taxonomy, with a sort by radio button. I just want that when I get on the page this is the "active" taxonomy that is selected.
And I also want to keep the display in alphabetical order when sorting, which is not the case at the moment (see screenshot).
Here is the page in question : hidden link
Than you
Olivier

#626583

OK, since this is a taxonomy search you cannot proceed like instructed earlier, since there is no native feature for the goal you try to achieve.

What you can do is this:
- create the View as usual
- wherever you link to this View, please edit the Link and add the URL parameter to the first option checked is set already, when the visitor visits the page with this View:

<em><u>hidden link</u></em>

Please adapt the "?wpv-category=one" part.
"wpv-category" will be the URL parameter as seen in the View Query Filter Settings, and "one" is the exact term slug you want to use as default.

This also keeps the order you choose when inserting the Custom Filter ShortCode.

#626595

ok, i understood, how can i display in alphabetical order. When I load the page the sort is good but when I click on a button the order disappears.

#626597
Bildschirmfoto 2018-03-20 um 09.23.05.png

Are we talking about the order of posts or the order of the terms in the search?

If this is about the search:
- please edit the custom filter shortcode
- find the order by settings as shown in the screenshot

if this is about the order by in the posts list itself, it's not related to this ticket here.
In that case, we are happy to assist this in a new ticket.

#626600

It's about the order of the posts.

New threads created by Beda and linked to this one are listed below:

https://toolset.com/forums/topic/how-to-order-by-in-a-view/

#626605

OK, then we can handle this in a new ticket.
https://toolset.com/fr/forums/topic/how-to-order-by-in-a-view/

Thanks.