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.
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.
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.
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.
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:
/* Template Name: Full Width Template */
Now you will see the full-width page template in the settings. You can now apply it to any of the existing pages.
WordPress themes also provide sidebar on blog pages. You can also remove sidebar from the blog pages with the steps mentioned below:
If the full-width template is missing, then you will have to create it manually as we discussed above for a static page.
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.
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
As a visitor of the site and website owner, it is awful to experience errors on the site. Error pages… Read More
In the present context, every business owner maintains their own site for the online presence. When something unexpected happens with… Read More
If there are too many images on your site, they are uploaded in either PNG or JPG format. Learning how… Read More