Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Sticky side bar as per example

  • Hello,

    How can I make a sticky sidebar as per the example below:
    https://i.postimg.cc/8zVnT6kN/sample-right-side-bar.jpg

    With a title bottom border, a round thumbnail, categories, and customized font features.

    I have already created a right sidebar with the widget, but I don’t know how to customize the features above. And it’s not sticky.

    I put the website example on the Private Information below, as well as other information needed. Thank you!

  • Hi there,

    Create a new Block Element – Right Sidebar, switch to Code Editor and paste this markup:

    
    <!-- wp:generateblocks/headline {"uniqueId":"96b0cc08","element":"h4","blockVersion":3,"flexBasis":"100%","iconColor":"var(\u002d\u002daccent)"} -->
    <h4 class="gb-headline gb-headline-96b0cc08 gb-headline-text">Most popular</h4>
    <!-- /wp:generateblocks/headline -->
    
    <!-- wp:generateblocks/query-loop {"uniqueId":"1a2b8d01","query":{"post_type":"post","per_page":"6"}} -->
    <!-- wp:generateblocks/grid {"uniqueId":"ca33760c","columns":1,"verticalGap":10,"isDynamic":true,"blockVersion":3,"isQueryLoop":true,"useLegacyRowGap":true,"lock":{"remove":true}} -->
    <!-- wp:generateblocks/container {"uniqueId":"5c7c4cab","isGrid":true,"isQueryLoopItem":true,"gridId":"ca33760c","isDynamic":true,"blockVersion":4,"display":"flex","flexDirectionTablet":"column","flexDirectionMobile":"row","columnGap":"20px","rowGapTablet":"10px","sizing":{"width":"100%","height":"100%","maxWidth":""},"lock":{"remove":true,"move":true}} -->
    <!-- wp:generateblocks/container {"uniqueId":"3df7c017","isDynamic":true,"blockVersion":4,"flexShrink":0,"flexBasis":"80px","sizing":{"width":"","widthTablet":"66.66%","widthMobile":"50%","height":"","maxWidth":""},"typography":{"textAlignTablet":"left"}} -->
    <!-- wp:generateblocks/image {"uniqueId":"92236877","sizeSlug":"thumbnail","width":"80px","height":"80px","objectFit":"cover","blockVersion":2,"borders":{"borderTopRightRadius":"50%","borderBottomRightRadius":"50%","borderBottomLeftRadius":"50%","borderTopLeftRadius":"50%"},"useDynamicData":true,"dynamicContentType":"featured-image"} /-->
    <!-- /wp:generateblocks/container -->
    
    <!-- wp:generateblocks/container {"uniqueId":"3d6aadc7","verticalAlignment":"center","isDynamic":true,"blockVersion":4,"display":"flex","flexDirection":"column","justifyContent":"center","flexShrink":1,"sizing":{"width":"","widthTablet":"100%","widthMobile":"50%","height":"100%","maxWidth":""}} -->
    <!-- wp:generateblocks/headline {"uniqueId":"5de65b61","element":"h6","blockVersion":3,"typography":{"fontSize":"12px"},"spacing":{"marginBottom":"8px"},"useDynamicData":true,"dynamicContentType":"terms","termTaxonomy":"category"} -->
    <h6 class="gb-headline gb-headline-5de65b61 gb-headline-text"></h6>
    <!-- /wp:generateblocks/headline -->
    
    <!-- wp:generateblocks/headline {"uniqueId":"1cf7ebe2","element":"h3","blockVersion":3,"typography":{"fontSize":"15px"},"spacing":{"marginBottom":"5px"},"useDynamicData":true,"dynamicContentType":"post-title","dynamicLinkType":"single-post"} -->
    <h3 class="gb-headline gb-headline-1cf7ebe2 gb-headline-text"></h3>
    <!-- /wp:generateblocks/headline -->
    <!-- /wp:generateblocks/container -->
    <!-- /wp:generateblocks/container -->
    <!-- /wp:generateblocks/grid -->
    <!-- /wp:generateblocks/query-loop -->
    

    That should give you the layout like the example you provided.

    Once that’s done, we can add the sticky feature afterward.

  • Hi Alvind,

    I created a new element called Right Sidebar with the markup you provided and customized it as I wanted. Now, how to add the sticky feature?

    Thanks!

  • Give this CSS a shot:

    @media (min-width: 769px) {
        .single .inside-right-sidebar {
            position: sticky;
            top: 70px;
        }
    }

    Learn how to add CSS: https://docs.generatepress.com/article/adding-css/

    Let me know if this helps 🙂

  • Hi Leo,

    I tried adding that CSS using the Simple CSS plugin as well as Additional CSS as per the link you suggested. Both don’t work.

  • I just checked your sidebar, and it looks like the sticky effect is already applied.

  • It seems like the sticky effect is only applied to single posts. Both archive and static pages are not sticky. It’s clearly shown on long static pages like https://chonawrites.com/privacy-policy/ or https://chonawrites.com/terms-and-conditions/, the sidebar is not sticky.

  • I initially thought you wanted the sticky sidebar to apply only on single posts. If that’s the case, modify Leo’s CSS above to this:

    @media (min-width: 769px) {
        .inside-right-sidebar {
            position: sticky;
            top: 70px;
        }
    }
  • It works now! Thank you Alvind and Leo!

  • You’re welcome!

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