Widgets make it super easy to add cool things to our WordPress sidebar. However, sometimes your sidebars can become much longer than the actual content area. Recently a user asked if there was a way to automatically make the sidebar height the same as the content area to make it symmetrical. In this article, we will show you how to auto adjust WordPress sidebar to match the content height.
Video Tutorial
If you don’t like the video or need more instructions, then continue reading.
First you need to install and activate the SidebarAutomizer plugin. Upon activation, go to Settings » sidebarAutomizer to configure the plugin.
You can auto adjust the height of your sidebar by entering the div ID or Class for the content and sidebar containers. These values are different for each theme which is why the plugin cannot auto detect them. Finding these values is easy. All you need to do is open your website in Google Chrome, and open Inspect Element by right clicking anywhere on your website.
This will split your browser screen into three sections. On the bottom left screen, you will be able to see the HTML source code for your page. Moving your mouse over different elements in the HTML source will highlight them in the upper window. You need to find the div containing the main content area.
As you can see, in the screenshot above the div containing the content area uses the ID primary and class site-content.
Repeat the inspect element process once again to find the div ID or Class used for sidebar and for the single widget element.
That’s all. You can now save your settings. Visit a page on your website where the sidebar height is supposed to be longer than the content area. You will notice that the plugin will automatically hide the extra widgets to adjust the sidebar height.
We hope this article helped you auto adjust WordPress sidebar to match content height. You may also want to check out how to show / hide widgets on specific WordPress pages.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.
Thanks, I was looking for the solution and got it here. Once again thanks for your help.
Hi! Thanks for this post. This functionality has been in the back of my head for the longest time–so thanks for finding a solution!
Is there anyway we can do it the other way around?
The plugin matches the height of the sidebar to the height of the main content div. Is there anyway we can have the main content div match whatever length the sidebar div is?
Thanks in advance!
~ Roselle
Hi,
I think this is a very nice plugin, but I can’t seem to find the right id or class to fill in at the settings.
And what exactly does “aside” mean? No idea what to put there.
Here are my sites:
Johanna
Hello Johanna
Did you ever find a solution? I’m trying to figure it out as well.
Thanks
Joey
Take a look at this tutorial How to Create a Sticky (floating) sidebar widget in WordPress
Thanks for the video, but do you happen to know of a plugin that allows to show your sidebar banner (the one you choose) all the time the user scrolls up and down. Basically, it’s always in the view port of the browser.