Site logo

Archived topic

Sticking last widget in sidebar using elements?

3 replies · Started by gedosan on July 18, 2020

Viewing posts 1–4 of 4

Hi Guys

I am using an element (a hook) to show something at the end of the right sidebar. Is there a way to make this stick to the end of the sidebar the same way Q2W3 Fixed Widget works? I don't want to use that plugin as I have ads running on other pages that stick the ads to the sidebar, and I don't want it interfering with that.

By the way, if I can get this to work I'd want to add a load of these sidebar hooks, one per page. Hopefully there's a way of doing it via a bit of PHP.

Check out the page below. It's not the final design yet (obviously) but want to know if its possible before I start improving it.

Thanks
G

Hi there,

This is a CSS method for sticking widgets:

@media (min-width: 769px) {
    .right-sidebar .site-content {
        display: flex;
    }

    .inside-right-sidebar {
        height: 100%;
    }

    #ID-of-sticky-widget {
        position: -webkit-sticky;
        position: sticky;
        top: 80px;
        z-index: 100;
    }
}

You can use the Browser inspector find the ID of the widget.
For example the advert widget you have you swap this:

#ID-of-sticky-widget

for:

#sidebar_btf_placeholder

Which won't work with that plugin running.
But you could remove the plugin and stick the widget before the advert to have both of them stick.

Amazing. I made it stick using the class rather than the ID. Assuming this is ok?

Yes, Classes are fine - just make sure they are unique or you may find they effect other widgets

Glad to be of help

This archived topic is closed to new replies.