Skip Navigation

[Closed] Search filter with large number of categories

This support ticket is created 3 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.

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 3 years, 1 month ago.

Author
Posts
#2223079

This might be a big ask but I have a website with over 16k categories. I want some sort of search filter but it's far too long a list to display them all at once. Is there a way of just displaying parent categories and then allowing the child categories to appear when clicked on? On a related note is it possible to exclude particular categories from showing up in the custom search filter that would also be handy. There might be better ways of achieving the something similar... basically I'm looking for an easy way for users to search thousand of categories making use of the parent/child relationship.

#2223247

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

There isn't any built-in support for the option of selecting parent terms, then child terms, grandchild terms etc.

What you want is something like a select2 control for the taxonomy input (see hidden link).

There, instead of listing all options your users would be able to start typing and see matching terms updated as they type.

For smaller sets of data you can use a static version, where a normal select input is added to the markup containing all of the options, and then the select2 library converts the select dropdown into something more helpful than a long list of options.

So you have an existing dropdown but convert it to select2, and that is something we'd be able to help you with.

But if you are talking about 16k options then this static version is not viable, you need a dynamic version where the select2 library makes ajax requests to the server as the user types to populate the options. That's rather more complex because you can't piggy back of the existing select dropdown inserted by the View, you would need to add your own, then set up the JS to add support for select2, and also write the server-side PHP which manages searching for matching terms based on the passed user input.

I think that's what you would need, but it would be outside the scope of support I'm afraid. You could consult the list of Toolset Contractors to see if someone could develop it for you if needs be (https://toolset.com/contractors/).

Regarding excluding certain terms from the options, please see this code snippet for details on how to achieve that: hidden link

The topic ‘[Closed] Search filter with large number of categories’ is closed to new replies.