Narrow the selectable categories for the search bar
-
When I make a search, I have the possibility to select a category on the right side. But it’s showing absolute all the categories. I don’t want this, I want to narrow it to the first or second levels maximum. How can I change this?
Also, I wanna be able to change this value according to the category in which the user is. Is that possible?
Attachments:
You must be
logged in to view attached files.
Hi,
Try to add the following PHP code snippet to the child theme functions.php file to do this. It will show only parent categories from the shop.
add_filter('basel_show_only_parent_categories_dropdown', '__return_true');
Regards
I have added your code and the result is that I have only 1 parent category (Cordonnerie) getting display in the dropdown altough I have 4 of them (Cordonnerie, Serrurerie, Horlogerie, Imprimerie). This is of course not the expected behavior. What I want is to show the 4 main categories just mentionned.
Attachments:
You must be
logged in to view attached files.
Hi,
Please, add the code now so we can check how it works. Currently, it displays all the categories.
Regards
I just activated the code. Please check again
Hello,
The categories are empty that is they are not shown.
Best Regards
Indeed. I just made a test by adding a product into the (currently) empty categories and your code is working fine.
Issue completed.
The topic ‘Narrow the selectable categories for the search bar’ is closed to new replies.