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

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1393313
    Pete

    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

    #1393714
    Pete
    #1393800
    David
    Staff
    Customer Support

    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 ?

    #1393894
    Pete

    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

    #1394115
    Leo
    Staff
    Customer Support

    Since your home page is the posts page, you can turn the sidebar off in the customizer:
    https://docs.generatepress.com/article/sidebar-layout/#blog-sidebar-layout

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.