Skip Navigation

[Resolved] How to limit custom search to specific items only?

This support ticket is created 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1110872

Hi,
I have a CPT called "Persons", with hundreds of posts of persons.
This CPT has 3 custom taxonomies:
- Person Classification: contains multiple classifications like author, speaker, musician, poet..etc
- Initial letter: contains the alphabet as terms, so visitors can filter the persons by the first letter of their first name.
- Century: contains the centuries as terms, so visitors can filter the persons that lived in a certain century.

i created a view that shows all persons. Visitors can choose any classification, which then shows the corresponding letters and available centuries..etc
the system is working perfectly fine. all 3 taxonomy filters are using url parameters.

however, i want to create a smaller version of this view showing only the content creators (e.g. authors, speakers, painters, but not soldiers, doctors..etc). I still want visitors to be able to filter using the initial letter and century, as well as going between the available author types that I chose (so they can filter the authors only, or speakers only..etc, but they should not see any of the classifications i did not choose, like soldiers or doctors).

i changed the "Person classification" filter from a url parameter to "one of the following" and ticked the terms i want to show in the dropdown list only, but this did not work. it made the view broken.

So i changed it to use a "shortcode" and added the slugs of the terms i want to show in the shortcode, but this one still did not work. this option seems to have some influence on the results, (As the outcome changes a bit from the previous trial), however the results are still meaningless an broken.

I need to know how to limit the available options of one filter, and leave the other two as is.

I provided login details, and the view that I am testing on is called: All Authors - speakers View

thanks.

#1111382

Hello,

In your case, it needs to apply two filters to the same taxonomy "Persons Classifications":
1) not soldiers, doctors..etc
2) taxonomy "Persons Classifications" field in custom search form

This is not possible within Views UI, you can apply only one of them to one view.

It needs custom codes, for example, you can try these:

1) Setup the view, filter by the URL parameter, the taxonomy "Persons Classifications" field in custom search form should be able to work

2) use filter hook wpv_filter_query to trigger a custom PHP function, in this function, exclude the specific term
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

3) In the front-end, setup some CSS/JS codes, hide the specific terms (soldiers, doctors..etc) in the dropdown menu "تصنيف الشخصيات"
hidden link