Get the Official WPSaviour App Now!

BlogThemes

How to Change the Sidebar Side in WordPress

Not too long ago, considered one of our readers requested us learn how to change the sidebar facet in a WordPress theme. We get this query lots the place customers wish to change their sidebar from left to proper, or proper to left. On this article, we’ll present you learn how to change the sidebar facet in WordPress.

Change sidebar side in WordPress

Why Change The Sidebar Aspect in WordPress

Usability consultants imagine that individuals scan pages from left to proper. They suggest placing the vital content material on the left in order that customers see the content material first. Nevertheless, this might be reversed in case your website is in a language that’s written in Proper to Left route.

Many WordPress websites use the everyday weblog format with two columns. One for the content material, and the opposite column for the sidebar.

A WordPress site with sidebar on the left side

If you’re simply beginning out a web site, then it’s best to choose a WordPress theme that has the sidebar in your most popular location.

Many themes have choices to change sidebar sides from theme settings. Nevertheless in case your theme doesn’t have this feature, then you’ll have to change sidebar sides manually.

Having mentioned that, let’s check out how one can simply change the sidebar facet in WordPress utilizing just a little little bit of CSS.

Altering Sidebar Aspect in WordPress utilizing CSS

Earlier than you make any modifications to your theme, it’s best to first contemplate creating a toddler theme. By utilizing a toddler theme, it is possible for you to to replace your father or mother theme with out dropping your modifications.

Secondly, it’s best to all the time create a backup of your WordPress website if you find yourself making direct modifications to your lively WordPress theme.

You will want an FTP client to edit your theme information. See our newbie’s information on learn how to use FTP to add information to WordPress.

Connect with your WordPress website utilizing the FTP shopper and go to your theme folder. It’s often positioned at:

/yourwebsite/wp-content/themes/your-theme-folder/

Now you have to obtain and open your theme’s important stylesheet file in a plain textual content editor like Notepad. This file is known as fashion.css, and it’s positioned in your theme’s root listing.

On this file, discover the CSS class in your sidebar. It’s often .sidebar. On this instance, we’re utilizing the default WordPress theme Twenty Fifteen which has this CSS to outline sidebar:

1
2
3
4
5
6
7
.sidebar {
        float: left;
        margin-right: -100%;
        max-width: 413px;
        place: relative;
        width: 29.4118%;
    }

As you’ll be able to see it floats sidebar to the left with a margin of -100% to the precise. We are going to change it to drift proper and margin-left like this:

1
2
3
4
5
6
7
.sidebar {
        float: proper;
        margin-left: -100%;
        max-width: 413px;
        place: relative;
        width: 29.4118%;
    }

Save your modifications and add fashion.css file again to your web site utilizing FTP shopper. Now for those who go to your web site, it should appear to be this:

Sidebar moved but content side is still the same

That’s as a result of now we have moved the sidebar however we didn’t transfer the content material space. Twenty Fifteen makes use of this CSS to outline the place of content material space.

1
2
3
4
5
6
.site-content {
        show: block;
        float: left;
        margin-left: 29.4118%;
        width: 70.5882%;
    }

We are going to change it to maneuver content material to the precise. Like this:

1
2
3
4
5
6
.site-content {
        show: block;
        float: left;
        margin-right: 29.4118%;
        width: 70.5882%;
    }

That is how our web site sorted making use of this CSS.

A CSS conflict showing an empty white area

As you’ll be able to see that now we have switched sides for each content material and sidebar areas. Nevertheless there’s nonetheless a white block on the left.

You’ll come throughout such issues if you find yourself working with CSS. It can take some detective work to determine what’s inflicting that and learn how to regulate it.

Use your browser’s ‘Examine’ device to have a look at the supply code. Level your mouse to the affected area within the browser, right-click and choose Examine from browser menu.

Inspect tool

As you progress your mouse within the supply code view, you’ll discover the areas it impacts highlighted within the stay preview. In the precise pane, it is possible for you to to see the CSS used for that chosen factor.

We found out that this CSS in our stylesheet wants adjusting.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@media display screen and (min-width: 59.6875em) {
    physique:earlier than {
        background-color: #fff;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
        content material: "";
        show: block;
        top: 100%;
        min-height: 100%;
        place: mounted;
        high: 0;
        left: 0;
        width: 29.4118%;
        z-index: 0; /* Fixes flashing bug with scrolling on Safari */
    }

This CSS code provides an empty content material block of 29.4118% width and 100% width to the highest left. Right here is how we’ll transfer it to proper.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@media display screen and (min-width: 59.6875em) {
    physique:earlier than {
        background-color: #fff;
        box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
        content material: "";
        show: block;
        top: 100%;
        min-height: 100%;
        place: mounted;
        high: 0;
        proper: 0;
        width: 29.4118%;
        z-index: 0; /* Fixes flashing bug with scrolling on Safari */
    }

After saving and importing the stylesheet again to the server, that is how our web site regarded.

sidebar moved to the other side

Working with CSS will be complicated for freshmen. Should you don’t wish to do all of the handbook code work, then you could wish to strive CSS Hero. It lets you edit CSS with out writing any code, and it really works with each WordPress theme.

We hope this text helped you modify the sidebar facet in WordPress. You may additionally wish to see our listing of 12 WordPress sidebar methods to get most outcomes.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogShowcase

7 Best Shopify Alternatives in 2020 (Cheaper and More Powerful)

Beginner’s GuideBest WordPress PluginsBlog

14 Best AI Chatbots Software for Your Website (Comparison)

Beginner’s GuideBlogTips

Magento vs WooCommerce – Which one is Better? (Comparison)

Beginner’s GuideBlogTips

12 Best Calculator Plugins for Your WordPress Site

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.

Fear Of Missing Out?

Sign up with your email address to receive WordPress tips and updates
SUBSCRIBE NOW
Terms and Conditions apply
close-link
Click Me