Recently, one of our readers asked us how to change the sidebar side in a WordPress theme. We get this question a lot where users want to change their sidebar from left to right, or right to left. In this article, we will show you how to change the sidebar side in WordPress.
Why Change The Sidebar Side in WordPress
Usability experts believe that people scan pages from left to right. They recommend putting the important content on the left so that users see the content first. However, this could be reversed if your site is in a language that is written in Right to Left direction.
Many WordPress sites use the typical blog layout with two columns. One for the content, and the other column for theΒ sidebar.
Β Β Β Β Β Β Β Β float: left;
Β Β Β Β Β Β Β Β margin-right: -100%;
Β Β Β Β Β Β Β Β max-width: 413px;
Β Β Β Β Β Β Β Β position: relative;
Β Β Β Β Β Β Β Β width: 29.4118%;
Β Β Β Β }
As you can see it floats sidebar to the left with a margin of -100% to the right. We will change it to float right and margin-left like this:
Β Β Β Β Β Β Β Β float: right;
Β Β Β Β Β Β Β Β margin-left: -100%;
Β Β Β Β Β Β Β Β max-width: 413px;
Β Β Β Β Β Β Β Β position: relative;
Β Β Β Β Β Β Β Β width: 29.4118%;
Β Β Β Β }
Save your changes and upload style.css file back to your website using FTP client. Now if you visit your website, it will look like this:
Thatβs because we have moved the sidebar but we did not move the content area. Twenty Fifteen uses this CSS to define the position of content area.
Β Β Β Β Β Β Β Β display: block;
Β Β Β Β Β Β Β Β float: left;
Β Β Β Β Β Β Β Β margin-left: 29.4118%;
Β Β Β Β Β Β Β Β width: 70.5882%;
Β Β Β Β }
We will change it to move content to the right. Like this:
Β Β Β Β Β Β Β Β display: block;
Β Β Β Β Β Β Β Β float: left;
Β Β Β Β Β Β Β Β margin-right: 29.4118%;
Β Β Β Β Β Β Β Β width: 70.5882%;
Β Β Β Β }
This is how our website looked after applying this CSS.
As you can see that we have switched sides for both content and sidebar areas. However there is still a white block on the left.
You will come across such things when you are working with CSS. It will take some detective work to figure out whatβs causing that and how to adjust it.
Use your browserβs βInspectβ tool to look at the source code. Point your mouse to the affected region in the browser, right-click and select Inspect from browser menu.
As you move your mouse in the source code view, you will notice the areas it affects highlighted in the live preview. In the right pane, you will be able to see the CSS used for that selected element.
We figured out that this CSS in our stylesheet needs adjusting.
Β Β Β Β body:before {
Β Β Β Β Β Β Β Β background-color: #fff;
Β Β Β Β Β Β Β Β box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
Β Β Β Β Β Β Β Β content: “”;
Β Β Β Β Β Β Β Β display: block;
Β Β Β Β Β Β Β Β height: 100%;
Β Β Β Β Β Β Β Β min-height: 100%;
Β Β Β Β Β Β Β Β position: fixed;
Β Β Β Β Β Β Β Β top: 0;
Β Β Β Β Β Β Β Β left: 0;
Β Β Β Β Β Β Β Β width: 29.4118%;
Β Β Β Β Β Β Β Β z-index: 0; /* Fixes flashing bug with scrolling on Safari */
Β Β Β Β }
This CSS code adds an empty content block of 29.4118% width and 100% width to the top left. Here is how we will move it to right.
Β Β Β Β body:before {
Β Β Β Β Β Β Β Β background-color: #fff;
Β Β Β Β Β Β Β Β box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
Β Β Β Β Β Β Β Β content: “”;
Β Β Β Β Β Β Β Β display: block;
Β Β Β Β Β Β Β Β height: 100%;
Β Β Β Β Β Β Β Β min-height: 100%;
Β Β Β Β Β Β Β Β position: fixed;
Β Β Β Β Β Β Β Β top: 0;
Β Β Β Β Β Β Β Β right: 0;
Β Β Β Β Β Β Β Β width: 29.4118%;
Β Β Β Β Β Β Β Β z-index: 0; /* Fixes flashing bug with scrolling on Safari */
Β Β Β Β }
After saving and uploading the stylesheet back to the server, this is how our website looked.
Working with CSS can be confusing for beginners. If you donβt want to do all the manual code work, then you may want to tryΒ CSS Hero. It allows you to edit CSS without writing any code, and it works with every WordPress theme.
We hope this article helped you change the sidebar side in WordPress. You may also want to see our list ofΒ 12 WordPress sidebar tricks to get maximum results.
If you liked this article, then please subscribe to ourΒ YouTube ChannelΒ for WordPress video tutorials. You can also find us onΒ TwitterΒ andΒ Facebook.