How to Remove Sidebar in WordPress

How to Remove SideBar in WordPress - CodeFlist

A sidebar is a place for widgets that can appear in right, left, or at the bottom after the content on different pages. In case if you do not need a widget in a post or page, you need to learn how to remove Sidebar in WordPress. Depending on the theme, the settings for sidebar removal are also provided for ease. However, if it is not provided, this tutorial will be helpful for you.

Why remove Sidebar in WordPress?

There are cases when you need to display different items in the sidebar. They can be advertisements, forms, social shares, etc. and can be added using widgets. The experience of users can be different depending on whether they are viewing the site from desktop or mobile. It is because sidebar options may be different for a mobile device. The width is reduced in mobile devices, so left and right sidebars may appear towards the bottom.

Depending on the requirement of the client, the developers have to enable or disable the sidebar to improve the user experience and productivity of the site.

How to Remove Sidebar in WordPress Completely

Before you start doing this method, it is recommended to keep a backup of the site and use the child theme to prevent losing the changes that you will make when you will update the theme later. 

This method will kick out the sidebar completely from your theme. You need to edit theme files for this to happen. To access the theme files, either you can directly log in to the WordPress dashboard, log in to the File Manager from the hosting provider, or with the help of FTP Client.

As the theme contains multiple templates, you need to copy all of them before you start editing. You should edit entire templates where a sidebar is present. In a normal theme, they can be present on index.php, home.php, archive.php, single.php, page.php, and so on.

Find the folder where the template folder is located. Open wp-content/themes/theme-folder. Copy the template that you will edit to the child theme folder. Now look for this line in the template file:

<?php get_sidebar(); ?>

This function calls the sidebar. Thus, delete this code from the sidebar.

If your theme has multiple sidebars, then you need to search codes having a “sidebar” word. For example: 

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

The above sidebar code represents the footer widget. Find this type of code and remove them.

After saving the changes, you will observe that the sidebar has been removed from the website. Furthermore, you will see that even after removing the sidebars, the content width remains the same.

Every theme has defined a default content width for images and texts to appear, so you need to edit code for the full-width content area. This can be fixed by adding custom CSS to your theme. Inspect the content area and find out the CSS class that is used to define that particular content area.

Now you need to specify CSS code for that particular class. Here is an example for the sample CSS:

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

After you implement this additional CSS in your theme, you will see the full-width content area without sidebars.

How to Remove Sidebar in WordPress from Individual Pages

The sidebar may appear in different locations. Sometimes you need to remove a particular sidebar from a post or a page without affecting the display of the sidebar on other locations. This process is similar to the method we discussed above. Let’s have a closer look at it.

How to Remove Sidebar from a Static Page

When you edit a page, search for Page Attribute settings in the bottom right. You will find a full-width page template by default for a static page. They do not display sidebars on their page. Selecting the Full-Width page template is the solution for you.

However, if you do-not see Full-Width attribute settings, then it is not provided by your theme.

In such a case, you need to add a full-width template file manually. Follow these instructions to create one for you:

  • Create a new file named full-width.php with the help of a text editor.
  • Locate wp-content/themes/theme-name folder  with an FTP Client.
  • Copy code from page.php file and paste it in the full-width.php file.
  • Open <?php tag and enter the template name field as below:
/* Template Name: Full Width Template */
  • Search <?php get_sidebar(); ?> and delete it.
  • Save the changes and upload full-width.php file to the child theme folder via. FTP Client.

Now you will see the full-width page template in the settings. You can now apply it to any of the existing pages.

How to Remove Sidebar in WordPress from a Blog Page

WordPress themes also provide sidebar on blog pages. You can also remove sidebar from the blog pages with the steps mentioned below:

  • Firstly, Go to Settings >> Reading, check the Posts page mentioned.
  • Go to Pages >> All Pages, Edit the page that you found in the earlier step.
  • Change the page attribute to the full-width template before saving these changes.

If the full-width template is missing, then you will have to create it manually as we discussed above for a static page.

How to Remove Sidebar from a Single Post

If the theme provides a full-width post template, then it is easier to remove the sidebar from a post. In such a case you can edit an old post or create a new one with Post Attributes as Full-width template to remove the sidebar. However, if it is missing, you need to create a custom page template for a static page.

It is similar to removing sidebar from static pages and blog pages. However, you need to copy and edit contents from the single.php template file instead of page.php file.

How to Remove Sidebar in WordPress with a plugin

If you want to avoid the above processes, you can simply do it with the help of a plugin. There are different plugins in WordPress that can remove everything from the page to create a blank template. You can also remove sidebars, page title, etc. as well as you can get full-width content area after removing them. If you just want to remove the sidebar, the plugin does it too.

All you need to do is search for a suitable plugin from the WordPress plugins repository. If you are unable to find the plugin, let us know in the comments, we will recommend a plugin for it.

Conclusion

The Sidebar is one of the rich features of WordPress. However, there are cases when you no longer need it. Hopefully, you have learned how to remove Sidebar in WordPress.   

Further Reading

  1. How to duplicate a page in WordPress
  2. How to upload HTML File to WordPress
  3. Latest WordPress News
  4. How to unpublish WordPress site