Could you provide some more details about this? Where would you like to show this link? What filters would you like to remove when the link is clicked?
Ok I would create a "remove filter" badge for each active filter.
1. Filter Removing
Like on this page: hidden link
after the "La tua ricerca" there is a list of all active filters:
Ricevimento: is the custom post type selection
Ville Matrimoni: is the 1° Taxonomy (type of location)
Lazio & Roma: is the 2° Taxonomy (in our case Citta)
Genzano di Roma: is another taxonomy (we don't have, it is the district, and it depends of the città)
In our case:
Starting from a url like this: hidden link
Where:
eventi-aziendali is the 1° taxonomy
and
roma-centro is the 2° Taxonomy
The remove filters link should be like so:
a.
Remove 1° Taxonomy
[Roma Centro x ]
Linking to hidden link
b.
Remove 2° Taxonomy
[Eventi Aziendali x]
Linking to hidden link
(it could be better transform it to hidden link but it doesn't work)
2. Custom Search in Taxonomy page and filter
I'd like my Search to include also additional filters.
I'll try to explain better:
In the taxonomy view the search filters should be the same taxonomy but the user could search also for custom fields in the taxonomy view
i'll post images
3. It could be great to integrare the District like in question 1, but i don't think it is possibile
Okay I see what you mean now, thank you for the additional information. Toolset offers one shortcode wpv-filter-reset that can be used to create a link or button to reset all of a View's filters at the same time: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214912
However, there is nothing built-in to Views that will display a list of active filters, and there is no built-in way to remove filters individually. This type of interface will require a significant amount of advanced, custom JavaScript code. Unfortunately there is no JavaScript API available for custom search View filters, so the best way to interact with the filters is to trigger page reloads with modified URL parameters.
You would need a way to split the URL by "/" to create an array of paths. You can use JavaScript's "split" method to split the string up into components: https://www.w3schools.com/jsref/jsref_split.asp
Loop over those parameters and URL directories to create badge links. The link for filter1 should remove the filter1 URL parameter and value: hidden link
You would have to use JavaScript's String and Array manipulation methods to modify the URL for each link. The links should trigger a full page reload at the new URL. After the page reloads, the filter list should be regenerated.
Sure, i would apply this to toolset.
Actually i rewrote the urls of the orginal wordpress taxonomy because it doesn't work on toolset parameters.
It could be simplyest with toolset but i don't know why it does not work
Christian is currently on vacation at the moment, however based on what i've read you're trying to implement a fairly complex javascript to reset your filter parameters when a button is click.
I'm not 100% clear on the issue to continue assisting so if you can walk me through so that I can understand perhaps I can pickup where Christian left off.
Thanks,
Shane
The topic ‘[Closed] Create link badge to remove filters’ is closed to new replies.