• Hi there! Can anyone please help me with custom coding for my sidebar? I’ve tried messing around with some position:sticky coding, but I’m a CSS novice and I’m striking out. My goal is to make the final widget on my sidebar, the Related Posts widget, sticky, so that it remains visible as users scroll down the page. My related posts widget is added to my custom theme via the “Related Posts for WordPress” plugin via a CSS shortcode. Any suggestions would be greatly appreciated!

    Thanks,

    Meredith

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mkremer12

    Based on the above link you shared, you can try adding the following CSS in your additional CSS:

    .camille_post_sidebar .widget_rp4wp_related_posts {
    position: sticky;
    top: 100px; /* Adjust this if needed */
    z-index: 99;
    }

    .camille_post_sidebar,
    .camille_post_sidebar .camille-container,
    .camille_post_sidebar .widget-area {
    overflow: visible !important;
    }

    The above code should work for your website.

    Regards

    Hello @mkremer12 I have reviewed your concern. you can try adding this CSS to make your related posts widget sticky:

    .your-related-posts-class {
    position: sticky;
    top: 20px;
    }


    replace .your-related-posts-class with the actual class of your related posts widget. you can find this by right-clicking on the widget in your browser and selecting Inspect.
    If it doesn’t work ensure, the parent container does not have overflow: hidden or overflow: auto.
    May be the sidebar has enough height for sticky position to work.

    Hi Meredith! 👋

    You’re on the right track with position: sticky. To make your Related Posts widget sticky, try adding the following CSS to your theme’s Additional CSS section (Appearance → Customize → Additional CSS):

    .related-posts-widget { position: sticky; top: 100px; /* adjust this based on your header height */ z-index: 100; }

    Make sure:

    • The widget’s container (.related-posts-widget) doesn’t have a parent with overflow: hidden, scroll, or auto.
    • You’ve applied this class either directly to the widget or via a wrapper div.

    If you’re using a custom theme and the Related Posts plugin adds the content via a shortcode, you may need to wrap that shortcode in a <div class="related-posts-widget"> manually in your sidebar template or widget area.

    Let me know if that helps — happy to assist further! 😊

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Help with sticky sidebar?’ is closed to new replies.