Remove "All categories" from searchbar dropdown

I have been struggling with this and could not find a clear answer online.

Will putting a product search bar I have a dropdown visible with all the categories you can search in. I would just like to keep only the categories and remove the "all categories" option.

You can see the current search I would like to fix here : https://compare-tech.fr

Thank you to anyone who will be able to help :)

Topic categories Wordpress search

Category Web


Thank you for your help !

We are halfway there. The "All categories" only shows before anything else is selected. So I just need to change the default selected category.

I used this :

function wp_dropdown_categories( $args = '' ) { $defaults = array( 'selected' => 2, ); 

But it crashed my website.. that might not be it. Can anyone see my mistake ?


This list can be modified using WooCommerce filters. However, without a thorough testing I could not find a specific filter to help you. You might check the API for a better answer.

Meanwhile, I have used this CSS snippet to successfully hide the "All Categories" entry from the drop-down selector:

li.option[data-value=''] {
    display: none;
}

This will only prevent users from selecting "All Categories" again. It will not prevent your page from defaulting to "All Categories".

Hope this is helpful!

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.