Home Forums WoodMart support forum Product search – Hide Sidebar(filter) When No Products Found in Search Results

Product search – Hide Sidebar(filter) When No Products Found in Search Results

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #699057

    dheeraj.5689
    Participant

    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.
    #700161

    dheeraj.5689
    Participant

    Hello,

    Any update on this please?

    Best Regards,

    #700265

    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,

    #700422

    dheeraj.5689
    Participant

    No, its not working.

    Even i checked into the view source, there is no search-no-results class are rendering.

    #700517

    Hello,

    I have checked your site but the sidebar is not showing.

    See this screenshot: https://postimg.cc/zbJVzfM4

    Best Regards,

    #700573

    dheeraj.5689
    Participant

    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’;
    }
    }
    }

    #700664

    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.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Product search – Hide Sidebar(filter) When No Products Found in Search Results’ is closed to new replies.