We can display a related posts section, newsletter form, advertisements, and other important content in the website sidebar. The problem is that a normal WordPress sidebar scrolls out of view as visitors move down the page.
A sticky sidebar solves this problem by keeping selected sidebar content visible while the visitor scrolls through the page. I have used this feature on my blogs and tested different approaches for the content I want to keep visible.
In my experience, a simple CSS solution is usually enough when I only need a basic sticky sidebar. For more advanced requirements, such as making individual widgets sticky or controlling different elements on different devices, a dedicated plugin can be more convenient.

In this guide, I’ll show you how to make a sticky sidebar in WordPress without a plugin, how to create one in GeneratePress, how to make only one widget sticky, how to use WordPress blocks, and how to troubleshoot a sticky sidebar that isn’t working properly.
A sticky sidebar is a sidebar that remains visible as the visitor scrolls through the main content.
Unlike a normal sidebar, which moves upward and eventually disappears from the screen, a sticky sidebar uses CSS positioning to remain within its available container.
The most important CSS property is: position: sticky;
A top value is also normally required:
position: sticky;
top: 20px;The top value tells the browser where the element should stop while scrolling.
These two terms are often used interchangeably, but sticky and fixed positioning are not exactly the same.
| Sticky Sidebar | Fixed Sidebar |
| Uses position: sticky | Uses position: fixed |
| Starts in its normal document position | Removed from normal document flow |
| Becomes sticky after reaching the specified offset | Remains fixed relative to the viewport |
| Constrained by its containing block | Generally positioned relative to the viewport |
| Usually easier to use for sidebars | Can require additional layout adjustments |
For most WordPress content websites, I prefer position: sticky because it works naturally with the existing page layout.
You don’t necessarily need a WordPress plugin to create a sticky sidebar. Modern browsers support CSS position: sticky, so a small amount of CSS is often enough.
Here’s a basic example:
@media (min-width: 769px) {
.your-sidebar {
position: sticky;
top: 20px;
}
}Replace .your-sidebar with the CSS class used by your website’s sidebar.
Why use a media query?
I recommend applying the sticky effect only to desktop and larger screens in most cases.
The sidebar layout on a mobile phone is very different from a desktop layout. A sticky sidebar can consume a large portion of the mobile viewport and make scrolling uncomfortable.
That’s why I normally use: @media (min-width: 769px) {
This means the sticky effect will apply only when the screen is at least 769px wide.
The CSS selector will vary depending on your WordPress theme.
If you’re not sure which selector to use, you can find it using your browser’s developer tools.
Step 1: Open your website, visit the page containing your sidebar.
Step 2: Right-click the sidebar; choose Inspect or Inspect Element.
Step 3: Look at the HTML. Find the container surrounding your sidebar.
You may see something similar to:
<aside class=”widget-area”> or <aside id=”right-sidebar”> or another theme-specific class.
Step 4: Use that selector in your CSS
The exact selector depends on your theme and website structure, so don’t assume that the same selector works on every WordPress website.
GeneratePress is one of the WordPress themes where creating a sticky sidebar with CSS is relatively straightforward. I’ve worked with this on WordPress websites and I prefer using CSS rather than adding another plugin.
If you’re using the classic GeneratePress theme with a right sidebar, add the following CSS through
Appearance β Customize β Additional CSS
@media (min-width: 769px) {
.inside-right-sidebar {
position: sticky;
top: 20px;
}
}Adjust the top spacing – If your website has a sticky header, 20px may not be enough.
For example:
@media (min-width: 769px) {
.inside-right-sidebar {
position: sticky;
top: 80px;
}
}The correct value depends on your header height. I recommend testing the page after adding the CSS instead of blindly copying a particular top value.
You don’t always need to make the entire sidebar sticky. In fact, there are situations where I prefer making only one element sticky.
For example, suppose your sidebar contains:
- Search widget
- Categories
- Recent posts
- Newsletter form
- Affiliate CTA
You may want only the newsletter form or CTA to remain visible.
Depending on your GeneratePress layout, you can target the last sidebar element with CSS such as:
@media (min-width: 769px) {
.inside-right-sidebar > *:last-child {
position: sticky;
top: 80px;
}
}This approach is useful when you want to keep a particular CTA visible without making the entire sidebar sticky.
However, the exact selector depends on how your widgets are structured. Always inspect the HTML if the CSS doesn’t behave as expected.
How to Make a WordPress Widget Sticky?
You can also target an individual widget instead of the entire sidebar.
For example, if your widget has a unique CSS class:
@media (min-width: 769px) {
.my-sticky-widget {
position: sticky;
top: 80px;
}
}This gives you more control over your WordPress sidebar.
If you’re using a modern block theme, the process can be different from the traditional WordPress Widgets interface. Block themes use the Site Editor, and the available options depend on your theme and WordPress version.
In supported block editing environments, you can use the block’s position settings to create sticky elements. A typical workflow is:
- Open the Site Editor or relevant template.
- Select the sidebar or the Group containing your sidebar content.
- Make sure the content you want to keep together is inside the appropriate container.
- Look for the Position settings in the block options.
- Choose Sticky, when available.
- Configure the top offset if the editor provides the option.
- Preview the page on desktop and mobile.
The exact interface can vary depending on your theme and WordPress installation.
If your block theme doesn’t provide a sticky-position control, CSS remains an option.
A plugin can make things easier when you want more control without manually writing CSS. Here are some options worth considering.
WP Sticky
WP Sticky is designed for making different website elements sticky. It provides a visual element selection approach, which can be useful if you don’t want to identify CSS selectors manually.
You can stick the sidebar, menu, CTAs, widgets and other fixed website elements. If you’re managing multiple sticky elements, a dedicated plugin can save time compared with writing custom CSS for each element.
WP Sticky Sidebar
WP Sticky Sidebar is another option specifically focused on sticky sidebar functionality.
It’s worth considering if you want a simpler sidebar-focused solution rather than a broader sticky-element tool.
CSS vs Plugin vs WordPress Blocks
Which Method Should You Use? Here’s how I would choose the method:
| Method | Best for | Technical knowledge |
| CSS | Simple sticky sidebar | Basic CSS |
| GeneratePress CSS | GeneratePress websites | Basic CSS |
| WordPress Blocks | Block themes with sticky positioning | Beginner |
| Sticky plugin | Multiple sticky elements | Beginner |
| Custom CSS + selectors | Advanced customization | Intermediate |
For my own WordPress work, I prefer CSS when the requirement is simple. Adding another plugin for a small CSS task isn’t always necessary.
On the other hand, if you need visual controls, multiple sticky elements, or device-specific settings, a plugin can be more convenient.
This is one of the most common problems people encounter after adding: position: sticky;
If your sidebar doesn’t stick, don’t immediately assume the CSS is wrong. Several layout conditions can prevent sticky positioning from behaving as expected.
1. Check the top Value
Make sure you have defined a top offset:
position: sticky;
top: 20px;Without an appropriate inset value, the sticky behavior may not work as expected.
2. Check the Parent Container
This is one of the most important troubleshooting steps. An ancestor element with certain overflow settings can interfere with sticky positioning.
For example, check whether a parent container has:
overflow: hidden; or overflow: auto; or overflow: scroll;
If your sticky sidebar isn’t working, inspect the parent elements and check their CSS.
3. Check the Height of the Sidebar
If the sticky element is taller than the available viewport or its containing area, there may not be enough space for the expected sticky behavior. Try reducing unnecessary sidebar content and test again.
4. Check the Containing Block
A sticky element is constrained by its containing block. If the parent container ends earlier than expected, the sidebar will stop being sticky when it reaches that boundary. This is normal CSS behavior rather than a WordPress bug.
5. Check for Conflicting CSS
Another CSS rule may override your sticky declaration.
Use your browser’s Inspect tool and check whether: position: sticky; is being overridden by another rule.
You may also find that the theme or page builder applies a different positioning rule.
6. Check Your Header Height
If your header is sticky, don’t use: top: 0; without testing it.
Your sidebar may disappear behind the header. Try: top: 70px;
7. Check Your Mobile Breakpoint
If you’ve used: @media (min-width: 769px) {
the sticky effect won’t apply below 769px.
That’s intentional. If you want a different breakpoint, change it according to your layout.
A common question is: Why does my sticky sidebar overlap the footer?
Remember that sticky positioning is constrained by its containing block. The sidebar doesn’t simply remain fixed forever.
If your layout isn’t structured correctly, the sticky element may visually collide with another section or appear to overlap the footer.
Check:
- Sidebar height
- Parent container
- Footer spacing
- Overflow properties
- Theme layout
- Sticky offset
- Custom CSS
- Page builder containers
If you’re using a page builder, inspect the parent containers carefully because their layout settings can affect sticky positioning.
In most cases, I recommend being cautious with sticky sidebars on mobile. A desktop sidebar may occupy only a small portion of the screen. On a mobile device, however, a sticky element can consume a significant part of the available viewport.
For this reason, I normally use a desktop-only rule:
@media (min-width: 769px) {
.inside-right-sidebar {
position: sticky;
top: 20px;
}
}This allows the sidebar to behave normally on smaller screens. Always test the actual mobile experience instead of assuming that desktop behavior will translate well to phones.
My Experience
I’ve worked on WordPress websites for years, and I’ve found that the best sticky-sidebar setup depends heavily on the purpose of the sidebar.
On WPGlossy, I’ve used sidebar elements for things such as useful resources, promotional content, and calls to action.
Rather than making every sidebar widget sticky, I prefer thinking about which information is genuinely useful to the reader while they’re scrolling.
I’ve also found that desktop and mobile need to be treated differently. A sticky element that looks perfectly fine on a wide desktop screen can become intrusive on a smaller device.
My approach has become simple: start with CSS, test the actual page, check the mobile experience, and only introduce a plugin when I need more control.
Final Thoughts
A sticky sidebar is a small WordPress customization, but it can make a noticeable difference when used thoughtfully. Prefer the CSS method to enable this feature.
And if you need to control several sticky elements without touching CSS, a dedicated WordPress sticky plugin may be more convenient.
I don’t recommend making a sidebar sticky simply because you can. Choose the content, test the mobile experience, and make sure the sticky element helps your visitors.
I have all possible methods of making WordPress sticky sidebar including for GeneratePress theme. If you face any difficulty in implementing this feature, catch me through the comment section.



It’s really great resource for me, I was despirately searching for creating sticky sidebars without any plugin.
Thanks A Lot
Sakthi, this is some sweet coding here buddy. I love the look of a sticky sidebar. Makes things a bit more professional if done the right way. I reckon going sticky can boost conversions for specific ads too. Keep those eyes glued to it during the entire trip to your blog. Smart.
Ryan
Hey Sakthi
Indeed, a useful post.
I am using 2 widgets on the right sidebar but both are not fixed.
Will try to implement the above techniques to make them sticky.
Thanks
Hello Sakthi,
Another useful post from you.
We followed your previous tips about the last updated date and it was very useful. Now, this post helped me in adding a sticky sidebar without a plugin.
Previously, I was using Q2W3 Fixed Widget and now I have uninstalled it.
Your code did the trick easily.
It would be great if you can share another tutorial about showing the author bio on Generatepress without a plugin. I tried a few codes from Google but none worked.
Thanks in advance.
Itβs really great resource for me, I was despirately searching for creating sticky sidebars without any plugin.
Hi Sakthi,
Thanks for the wonderful article.
The sticky sidebar will make user interaction and user experience even better.
I use Wp Sticky Sidebar, it’s a very nice plugin and it’s simple to customize the options.
I have another blog where I can implement the Q2W3 Fixed Widget plugins.
Thanks & Regards
Sai Mithun
It’s really good resource for me.Thanks for idea.
I use wp sticky sidebar,its a very nice plugin.
You’re the god of Generatepress customizations. Please post more tutorials.
Sure, Keep Coming!
I am not a sticky sidebar on my blog yet. Thinking of using it after reading this article. Very useful one! Thanks for sharing Shakti!
Hey
amazing articles
This is really a great post and this will definitely help me making Sticky Sidebar!
Hi
Its is really helpful.
Thank you for sharing this great information .
Thanks, the code to make the last sidebar widget on GeneratePress works perfectly.
Hi Dear
Thanks for sharing this awesome tips to sticky widget in generatepress theme. I’m using your last widget sticky css code for my website sidebar… Now it’s looks professonal.
Great job.
Trivanks
Hey Sakthi,
Thanks for sharing the css code.. I was looking for it and you made my day… Thanks for helping me π
Hi Sakhti,
Thanks for your information, much help me
I love CSS code that you provide. Many times plugins can slow website speed. CSS code is good. Thanks for sharing.
Very Use Full Sir this is good for our website or blog
Very useful post. I have looking for this sticky sidebar for more than two days. Now it became clarified to me. Anyway thanks for this fantastic post.
Sticky sidebar enhance the chances to get clicks on your desired content. CSS Approach to make the sidebar sticky is really helpful. Using css than a plugin is better in sense of website page speed.
Overall good article. I enjoyed that.
Thanks
Hello,
It is working with the right sidebar, but when I use the same with the left-sidebar, the widget gets over the main content. Can you please help me fix this?
Hi Sakhti,
The code you have for sticking the last widget is not working. Please Fix.
The code is not working for responsive ads in Google Adsense. It works if your ads have a defined dimension.
Oh my god this blog has given me a superb sollution. Kepup the best work. Really thanks alot.
Such an excellent Blog! I like your content. I would Thanks for sharing this wonderful content. Its very useful to us.