Skip Navigation

[Resolved] Restrict filters by taxonomy to current CPT

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

Problem:
Want to Restrict filters by taxonomy terms to current CPT.

Solution:
You can try the option in Custom Search Settings >> Show only available options for each input -- Screenshot here: https://toolset.com/wp-content/uploads/2017/10/576468-Show_only_available_options_for_each_input.png?x56682

This support ticket is created 7 years, 1 month 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
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Thomas Garric 7 years, 1 month ago.

Assisted by: Noman.

Author
Posts
#576389
communiques.jpg

I'm displaying a filter with taxonomies in a sidebar on some CPT archive pages.

But because some taxonomy terms are shared between different CPTs, all taxonomy terms are visible in the filters.

For example, I have a CPT "press release" and it's using only the taxonomy terms 2015 and 2017. A "press article" is using the terms 2016 and 2017. On the press release archive all the year would be displayed no matter the taxonomy term is used or not.

Is there a way to change the filter behaviour?

Here is my filter code:

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="row filter_div">
<div class="form-group col-sm-12">
<label><span id="fa"><i class="fa fa-arrow-right" aria-hidden="true"></span>[wpml-string context="wpv-views"]Marques[/wpml-string]</label>
<div class="form-group div_toggled">
[wpv-control-post-taxonomy taxonomy="marque" type="checkboxes" hide_empty="true" url_param="wpv-marque"]
</div>
</div>
<div class="form-group col-sm-12">
<label><span id="fa"><i class="fa fa-arrow-right" aria-hidden="true"></span>[wpml-string context="wpv-views"]Dates de parution[/wpml-string]</label>
<div class="form-group div_toggled">
[wpv-control-post-taxonomy taxonomy="date-de-parution" type="checkboxes" hide_empty="true" url_param="wpv-date-de-parution"]
</div>
</div>
<div class="form-group col-sm-12">
<label><span id="fa"><i class="fa fa-arrow-right" aria-hidden="true"></span>[wpml-string context="wpv-views"]Références produits[/wpml-string]</label>
<div class="form-group div_toggled">
[wpv-control-post-taxonomy taxonomy="reference-produit" type="checkboxes" hide_empty="true" url_param="wpv-reference-produit"]
</div>
</div>
<div class="col-sm-12">
[wpv-filter-submit name="Filtrer" output="bootstrap"]
</div>
</div>
[/wpv-filter-controls]
[wpv-filter-end]

#576468

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Show only available options for each input.png

Hi Thomas,

Thank you for contacting Toolset support. You can try the option in Custom Search Settings >> Show only available options for each input -- please see attached screenshot.

To enable “Custom Search Settings” section, please click on “Screen Options” at the top right of the screen while you are on Edit WordPress Archive page.

This will resolve the issue hopefully. Thank you

#578437

Thanks Noman, with your solution and a bit of development we manage to achieve what we wanted.