Product search – Hide Sidebar(filter) When No Products Found in Search Results
-
Hello Support Team,
When performing a product search that returns 0 results, the sidebar(filter widget) still appears on the left as a blank white box (please see the attached screenshot).
Thank you in advance for your help.
Attachments:
You must be
logged in to view attached files.
Hello,
Any update on this please?
Best Regards,
Hello,
Please copy and paste the below given CSS code to Theme Settings > Custom CSS > Global CSS.
body.search-no-results .wp-block-wd-off-sidebar {
display: none !important;
}
Best Regards,
No, its not working.
Even i checked into the view source, there is no search-no-results class are rendering.
Hello,
I have checked your site but the sidebar is not showing.
See this screenshot: https://postimg.cc/zbJVzfM4
Best Regards,
Hello,
Yes, it works when no search result, however, sidebar still showing if any brands or categories don’t have any products. Anyways i managed this via Javascript with following code –
`if (document.querySelector(‘.woocommerce-no-products-found’)) {
const targetDiv = document.querySelector(‘.wd-content’);
if (targetDiv) {
const firstDiv = targetDiv.querySelector(‘div’);
if (firstDiv) {
firstDiv.style.display = ‘none’;
}
}
}
Hello,
Sound’s Good! That you have managed to resolve your issue by yourself,
Feel free to write back anytime. If you need further assistance, we are always here to help you.
Thanks for contacting us.
Best Regards.
The topic ‘Product search – Hide Sidebar(filter) When No Products Found in Search Results’ is closed to new replies.