Wednesday 17 May 2017

How to Remove the Sidebar in WordPress

Do you want to remove the sidebar from your WordPress site? A sidebar is the widget-ready area in your WordPress theme. It often appears at the right or left side or below the content area on every page. In this article, we will show you how to easily remove the sidebar in WordPress.

How to Remove the Sidebar in WordPress

Why Remove the Sidebar in WordPress?

Most free and paid WordPress themes come with multiple sidebars or widget ready areas.

The purpose of sidebars in WordPress is to display items that are not part of the post or page content. Usually these are links to different areas of your website, advertisements, email list signup forms, social media profiles, etc. These items can be easily added to the sidebar of a theme using WordPress widgets.

Sidebar on a WordPress powered website

In most WordPress themes, sidebar appears differently when a user is viewing your site from a mobile device. Due to reduced width of the screen size, sidebars that appear on right or left on the desktop are moved to the bottom on mobile screens.

Sidebars are immensely helpful and can help you grow your business. See these WordPress sidebar tricks for maximum results.

However, some website owners feel that removing sidebar helps improve user experience. If you’re looking to remove the sidebar on your WordPress site, then this tutorial is for you.

Removing Sidebars From Everywhere in WordPress

This method allows you to simply remove sidebars from every page and post on your WordPress site. It requires you to edit WordPress theme files. If you haven’t done this before then see our guide on how to copy and paste code in WordPress.

First you need to connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder.

WordPress themes are made up of different templates, so you will need to edit all the templates where a sidebar is displayed.

For example, in a typical WordPress theme you may need to edit index.php, page.php, single.php, archive.php, home.php and so on.

Open a template file to edit it and then locate the line that looks like this:

<?php get_sidebar(); ?>

If your theme comes with multiple sidebars, then you will see different instances of this code with a sidebar name inside the function. For example:

<?php get_sidebar('footer-widget-area'); ?>

Delete the line that represents the sidebar that you don’t want to display.

Now, save and upload the file back to your website. Repeat the process for all template files responsible for displaying different pages on your website.

Once finished, you can go to your website and see it in action.

You may notice that while sidebars are gone, your content area is still appearing with the same width leaving the sidebar area empty.

Blank sidebar area in a WordPress theme

That’s because your theme has defined the width for the content area. Now that the sidebar is gone, you need to adjust the width of the content area by adding custom CSS to your theme.

First you will need to figure out the CSS class used by your theme to define the width of the content area. You can do that by using the Inspect tool in your browser.

Here is the sample CSS we used on our demo site using Twenty Sixteen theme.

.content-area {
    width: 100%;
    margin: 0px;
    border: 0px;
    padding: 0px;
}

.content-area .site {
margin:0px;
}

Here is how it looked without sidebars:

Sidebars removed from a WordPress theme

Removing Sidebars From Individual Pages in WordPress

It’s possible that you only want to remove the sidebars on certain pages while displaying them on other sections of your website.

For example, a lot of websites display sidebars on their blog page but not on individual blog posts. Some prefer to show sidebars everywhere except static pages.

Let’s take a look at different scenarios and how to remove sidebars from different areas.

Removing Sidebars from a Static Page in WordPress

Many WordPress themes come with ready-to use full width page templates. These templates can be used with any static page in WordPress and do not display sidebars on either side of the content.

You will just need to edit the page where you want to remove the sidebar and then select the full width template under ‘Page Attributes’ meta box.

Full width page template with no sidebars

If you do not see an option to select a template, then this means that your theme does not come with a full-width page template.

In that case, you will need to create a full-width page template manually. Open a plain text editor like Notepad and paste the following code in a blank file:

<?php
/*
*
Template Name: Full-Width
*/
get_header(); ?>

Now save this file as full-width.php on your desktop.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder. Edit the file called page.php and copy every thing that appears after <?php get_header(); ?> line.

Now paste this code in your full-width.php file. After that you need to locate and delete the line that looks like this:

<?php get_sidebar(); ?>

Save your changes and upload the full-width.php file to your current theme folder.

You can now edit any page on your WordPress site and you will be able to select your full width page template.

For more details, see our guide on how to create a full width page template in WordPress.

Remove Sidebar from Blog Posts Page in WordPress

WordPress allows you to use a static front page and a separate page for your blog posts. Usually, most WordPress themes display sidebars on the blog posts page.

If you don’t want to display sidebars on the blog posts page, then you need to go to Settings » Reading page. Notice the name of the page you are using as your blog posts page.

Find your WordPress blog page

Now go to Pages » All Pages and edit the page used to display your blog posts. Under the page attribute section select a full width template and then save your changes.

Full width page template with no sidebars

If you don’t see a full width template option, then you will have to manually create a full width template. See the previous section in this article for detailed instructions.

Remove Sidebar from a Single Post in WordPress

If you want to remove sidebar from certain single posts, then you can create a custom single post template.

WordPress 4.7 came with built-in support for post templates. You’d need to follow the steps outline in our guide on how to create custom single post templates in WordPress.

In your custom single post template all you need to do is make sure to remove the sidebar part of the code.

We hope this article helped you learn how to easily remove the sidebar in WordPress themes. You may also want to see our step by step guide on how to boost WordPress speed and performance.

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.

The post How to Remove the Sidebar in WordPress appeared first on WPBeginner.



source http://www.wpbeginner.com/wp-themes/how-to-remove-the-sidebar-in-wordpress/

No comments:

Post a Comment