Site logo

Archived topic

How to Hide a Sidebar Widget When It Has No Content?

4 replies · Started by Pete on August 8, 2020

Viewing posts 1–5 of 5

I am using Ezoic to display ads. This means while they may have a placeholder, their AI decides whether to place an advert inside a sidebar widget or not, with each page load. They automatically move ads around to test performance.

The result of this is sidebar widgets created that are placed including visible padded space when there are no ads some of the time. The padding in the otherwise empty widget pushes the GP Recent Posts widget downwards so it no longer lines up with the left content area; it has a widget above that's empty with just some padding creating unwanted space.

Is there any way to not show a widget when it's determined that it doesn't have content?

The best I've been able to do so far is make the widget the same background color as the theme background and to have no widget border, so it doesn't look as obviously empty.

Any suggestions?

Thank you

Hi there,

Not really possible without using JS and can't see that working too well as initially those widgets will be empty....
Why not just remove the padding from those Widgets ?

Hi David

Thanks for the reply.

I have sorted padding to find my way around it.

I still have the issue outlined in the other thread:
https://generatepress.com/forums/topic/widgets-not-showing-on-default-blog-home-page/#post-1393704

I'd like all other sidebar widgets to show on the GP default home page. Currently, only the Recent Posts one does because it's turned on through the Customizer. Ads are back now, so most page loads show these ad widgets. Only the Recent Posts show on the home page; inner posts often have additional widgets with ads shown. The latter never appear on the GP default home page and I don't see a way to turn sidebar widgets on for the home page. BTW, I'm talking sidebar widgets in general. These ads ones aren't anything special.

Any way to do so?

Thanks
Pete

This archived topic is closed to new replies.