Skip Navigation

[Resolved] How to search results from a filtered view

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 – 15:00 7:00 – 15:00 7:00 – 15:00 7:00 – 15:00 7:00 – 15:00 -
- - - - - - -

Supporter timezone: Pacific/Easter (GMT-06:00)

This topic contains 9 replies, has 3 voices.

Last updated by Ilyes 1 year, 1 month ago.

Assisted by: Ilyes.

Author
Posts
#2691055

I have a taxonomy named Document Types which lists all the different types of documents our website holds
I want to add a search on the site where only a select document types will show on the dropdown list of the search and not the whole list under document types.

I thought I could create a VIEW then filter the View to select the specific Document Types I want to show and from there use the SEARCH function to search from the selected items from the view. However the search overides the views filters resulting in a selection of DOCUMENT TYPES which then lists ALL the document types. I can't find a way to let the SEARCH function to search from the items filter from the VIEW. I found this article online https://toolset.com/forums/topic/post-types-view-with-taxonomy-filter-and-custom-search/ but I could not get it to work. I prefer to use the modern views as apposed to classic view which is probably why I could not get it to work as the instructions point to classic views.

Regards

#2691398

Ilyes
Supporter

Timezone: Pacific/Easter (GMT-06:00)

Hello,

Thank you for contacting Toolset support team,

It seems like you are trying to implement a search functionality on your website where you want to filter the search dropdown options based on specific Document Types from a taxonomy.

Here's a general approach to achieve this using Toolset's modern views and search functionality:

Create a View for Document Types:

- Go to Toolset > Views and create a new View.
- Select the 'Document Types' taxonomy to display its terms.
- Apply any necessary styling and settings to display the terms as a dropdown.

Filter the View to Show Specific Document Types:

- In the View settings, look for the filter or query options.
- Add a filter or query that only includes the specific Document Types you want to show in the dropdown. This might involve filtering by term IDs or slugs.

Use the Filtered View in the Search Function:

- In the search function settings or shortcode, specify the View you created for Document Types as the source for the dropdown.
- Make sure that the search function is set to use the dropdown from the View for Document Types.

Ensure Search Does Not Override View Filters:

- If the search function is overriding the View filters, you may need to use custom code or hooks provided by Toolset to prevent this behavior.

If you're facing challenges or specific issues with implementing this functionality, consider providing detailed information about the steps you've taken, any error messages, or unexpected behaviors encountered. This will help in providing more targeted assistance and solutions.

Best,

#2691407
Custom Search Settings 2.png
Custom Search Settings.png

Thank you for your reply, where do I do this "specify the View that I created for Document Types as the source for the dropdown".
Please see attached screenshot, of the options I have for the search function, I do not see a place I can specify.

Regards

#2691417

Ilyes
Supporter

Timezone: Pacific/Easter (GMT-06:00)

Hello again,

Is it possible if you could share a copy of your site or Admin access?

I could then potentially provide a step-by-step guide on how to set this up on your site, I could create a copy of your site using All In One WP migration so we avoid affecting your site.

There is a form below where you could share this information privately,

Best,

#2691636

Ilyes
Supporter

Timezone: Pacific/Easter (GMT-06:00)

Hello,

Thank you again for sharing the access, however, I had to delete it as it was shared publicly on our forum to protect your access,

I have re-opened the private field for you again, please fill the form below with the access,

Best,

#2692144

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Ilyes is not available today so I'll be responding in his place.

I tried importing the files but I'm getting an error while importing the DB: 'Variable sql_mode can't be set to the value of NULL'.

I apologize for the back and forth, but may I ask you to kindly replicate this issue in a sandbox so we can debug it and find a solution?

Login link: hidden link

Please login using the link above and let us know once you've been able to replicate this issue.

In addition to that, it'd be useful if you could try the instructions available here(https://toolset.com/forums/topic/post-types-view-with-taxonomy-filter-and-custom-search/) using the legacy view, I understand you would rather use the new Views available within Toolset Block, but that would help us identify if this could be a limitation with the new Views or perhaps some bug.

Please follow the steps outlined here to enable the legacy view for your testing: https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/#using-legacy-views

Thank you, please let us know and thank you for your understanding and help.
Mateus

#2692291

I have imported a theme on your installation. On that installation I created a MEDIA page.
The media page has a view which has a filter, the filter filters Document Types. On the Filter I selected 3 Document Types (Brochures, Guides and I think Speeches).

I then added a SEARCH function which is meant to Filter through the Document types I selected on the filtered view, however the Search Function creates it's own filter which overrides the filter created from the view. Furthermore the filter from the SEARCH function shows all ducument types instead of showing the document types that I chose when I was filtering the Document Types on the view. What I want to achieve is that the SEARCH filter must only filter from the 3 Document Types that I filtered from the View. If this is not clear, please refer to my previous replies as I have explained this before.

Regards

#2692877

Ilyes
Supporter

Timezone: Pacific/Easter (GMT-06:00)

Hello,

Thank you for your patience and I hope this email finds you well.

I wanted to address the issue you encountered with your View and front-end filter configuration. It appears that you have set up a View with a Query Filter to limit the results to specific document-types (taxonomy terms), and you've also attempted to create a front-end filter for these document-types.

However, it's important to note that you can't have both a front-end filter and a hard-coded Query Filter for the same taxonomy terms. Here's why:

When you use a front-end filter, it adds a Query Filter where the value to filter by comes from the selection made in the front end (via the URL parameter). Therefore, you cannot simultaneously filter by some hard-coded terms.

To resolve this issue, you should forget about the hard-coded Query Filter and focus on implementing the front-end filter control. After setting up the front-end filter, you can use the API, specifically the wpv_filter_query filter, to apply the hard-coded terms only when nothing has been selected in the front-end filter control.

Here's an example snippet to guide you through excluding some taxonomies from the filter: https://toolset.com/forums/topic/show-results-in-all-taxonomies-except-one/#post-1222978

Best,

#2692896

Thank you for your reply, It makes sense. However we use toolset cause it’s a powerful NO CODE builder. With that said, Is there no way of achieving the above without code and simply using your gui? There’s a specific instruction that no code must be used so that the site can be easily managed by anybody else.

Regards

#2693251

Ilyes
Supporter

Timezone: Pacific/Easter (GMT-06:00)

Hello,

For this to work, we need to either manipulate the query which is used to get the terms to include (e.g., specifying terms to exclude), using the filter wpv_filter_taxonomy_frontend_search_get_terms_args

Or we could use the filter wpv_filter_taxonomy_frontend_search_available_terms to manipulate the terms once they have been got, but before they are added to the select dropdown.

See https://toolset.com/documentation/programmer-reference/views-filters/

It is not something that can be done through the UI, but it is fairly straightforward to do with code.

If you think we could do it this way, and you need help with that, we could help you with it.

If you need help, please let me know,