Show only parent categories in searchbar

Is it possible to show only the parent categories in the searchbar? Or else, to hide some of the categories manually/via code?

The goal would be to shorten the list of categories in the searchbar and when clicking on the parent category, it would show the listings of all child categories.

Hi,

Unfortunately, there’s no such feature, it would require a custom implementation. If customizations are required for your site, please try customizing it using the collection of code snippets https://gist.github.com/search?q=user%3Ahivepress and other developer resources, or consider hiring someone for custom work Experts | HivePress

Thank you @andrii for your respons.

Would it be possible to guide me a bit in what snippets to look for or to what files to edit the functionality of the searchbar, to reach this goal of only showing parent categories?

If you’re familiar with coding, please try using the hivepress/v1/forms/listing_search filter hook to override the search form parameters, e.g. you can try overriding options for the _category field and set a strict list of category IDs to show, or change the option_args and pass parameters to change the categories query, it accepts the same parameters as this function get_terms() – Function | Developer.WordPress.org

Hope this helps

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.