• Resolved turbodb

    (@turbodb)


    I’ve been using Widget Options for a couple of years now and it is great.

    I have a widget (WooCommerce Cart) that I’ve added to the “Before Main Content” sidebar as the only widget in the sidebar. I’ve configured it to only show on post_type=Product posts using Widget Options; on all other posts/pages/taxonomies, Widget Options correctly hides the Cart widget.

    This is great, but the issue I’m having is that – while the widget is correctly hidden – the “Before Main Content” sidebar is not.

    My request is that if Widget Options hides all of the/the last widgets in a sidebar, then the sidebar should be hidden as well. This would mimic WordPress’ behavior when there are no widgets in a sidebar.

    If I remove the WooCommerce Cart widget from the “Before Main Content” sidebar on the /wp-admin/widgets.php page, the sidebar is not rendered/shown at all.

    Thanks! Dan

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mej de Castro

    (@mej)

    Hi @turbodb Thanks for reaching out and for using Widget Options. Can you please confirm if you want the entire sidebar be hidden (I mean to set the page in fullwidth) if there are no widgets to display?

    Thread Starter turbodb

    (@turbodb)

    In my case it is not the primary (side) sidebar, it is the top “Before Main Content” sidebar, which shows above the post content.

    In the “page I need help with” above, you can find it in the source as:

    <div class="sidebar sidebar-before-main-content active-1" id="sidebar-before-main-content"></div>

    That sidebar container (or any sidebar container) should be turned off/hidden when the last widget is removed by Widget Options.

    Plugin Author Mej de Castro

    (@mej)

    Gotcha! Hmm, I’m afraid we haven’t added a feature to hide/remove the widget container. Such feature is dependent to the theme settings, that in our case the theme will be affected/broken when we implement it.

    Meanwhile, with the help of Classes & ID. You can assign custom css classes and ID on each widgets for element targeting.

    For Example:
    https://snipboard.io/qWvVz9.jpg

    .sidebar-before-main-content-no-widget-show {
        display: none;
    }
    • This reply was modified 1 year, 12 months ago by Mej de Castro.
    Thread Starter turbodb

    (@turbodb)

    Thanks @mej, but there are two issues with that: (1) I don’t have the extended version of the plugin, just the free version, so I don’t have the option to assign custom CSS. (2) Wouldn’t that CSS class apply to the widget, not the sidebar itself?

    The widget itself is already hidden correctly; it is the (now dynamically empty) sidebar that needs to be hidden.

    Lastly – I don’t understand how “hide/remove the widget container…. [would be] dependent to the theme settings, [and] the theme will be affected/broken when we implement it.” Already, WP does not render the container when it is empty.

    In this case, WP thinks the container is not empty because the page flow is as follows:
    ***begin page render;
    ***rendering in progress
    ***widget1 added to before-main-content sidebar collection
    ******WordPress recognizes that before-main-content sidebar container should be rendered, to hold widget1
    ***more rendering
    ***Widget options runs and determines that widget1 should not be displayed on this page (for some reason); removes it
    ***more rendering until page complete

    Whereas, if there is no widget1 added to the before-main-content sidebar collection, the bold step never takes place.

    At least, that’s my understanding. Is that incorrect?

    If it is correct, then that step should be “undone” by Widget Options when the last widget is removed from a sidebar collection, in order to render the page as WordPress would have if there were never any widgets in that sidebar collection.

    Plugin Author Mej de Castro

    (@mej)

    Hi @turbodb , the Widget Options is for the widget content only. The widget container is out of scope of Widget Options plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sidebar area still shown when all widgets are hidden’ is closed to new replies.