Make pages full width when sidebar is not active

i would like to ask you if is there any way to hide sidebar when there is no widget .
I noted that in some themes, when I remove all widgets from the sidebar (Apparence -> Widgets), the sidebar disappear from the site and the content become 100% width. I want this!

But in some themes, even when I remove all widgets, it shows default widgets in the sidebar instead of hide it.

How to hide the sidebar when there is no widget? And let the content 100% width.

Thanks.

Hello @hitesh123,

If you are not using the sidebar and want to stretch your content to full width, then please try to use the following CSS code.

You can add CSS code to your site with Simple Custom CSS plugin (just copy CSS code and paste it in Dashboard -> Appearance -> Custom CSS after installing and activating the plugin). Also you can add CSS code directly to style.css file of your child theme.

#content #primary {
    width: 100%;
}

Please feel free to ask any other questions that you might have.

Kind Regards, Roman.

Hey Roman thanks for the quick reply ,i tried this code but it didn’t worked , it changes the page to full width and sidebar gets under the content area . What i want is when sidebar is active and has widgets then get the normal page template and when sidebar doesn’t have any widget then return with full width page template.

Is this possible by any way?

Thanks

Hello @hitesh123,

Yes, it is possible to make it happen automatically. But this task requires some coding and testing, so this goes beyond our support policy. It’s considered advanced customization.

As an option, you can contact Codeable for this kind of service, or find a freelancer on Upwork.

Kind Regards, Roman.