Skip to main content

How To Remove WordPress Sidebar For Specific Posts Or Entire Site

Looking for a way to remove the sidebar at your WordPress site? Most themes come with a sidebar of some sort, but you may not want to use it on all of your content (or even at all).

Elementor WordPress Page Builder

While a sidebar certainly gives you more space to put “stuff”, having more “stuff” isn’t always a good thing, and removing your site’s sidebar gives your site a clean, distraction-free look.

Or, you might want to remove it for other reasons – I’m not trying to get inside your head, I just want to help you remove your WordPress site’s sidebar!

To help you do that, I’ll show you how to do a few different things. You’ll learn how to…

  • Remove WordPress sidebar for specific pages, with a simple plugin or your own code.
  • Remove WordPress sidebar for your entire site, with your own code.
  • Show a different sidebar for different content with a plugin (this is kind of a bonus because it’s not technically removing your sidebar).

That’s a lot of sidebar removing goodness – let’s dive in!

A Quick, Simple Way To Hide The Sidebar – Consider This First

After this quick section, I’ll cover ways to truly remove the WordPress sidebar. However, I want to start with this little workaround because it’s super simple, and it may actually get you to where you need to be without any extra effort.

Basically, instead of removing the sidebar, you can just delete all of your sidebar widgets by going to Appearance → Widgets and removing every widget:

remove wordpress sidebar widgets

Now, it’s not perfect because your sidebar might still take up “space”. But it does hide any sidebar content. And if that’s all you’re looking for, this approach is totally fine.

Not enough? Want to actually remove the sidebar in WordPress or only remove the sidebar for certain content? Keep on reading!

How To Remove WordPress Sidebar For Specific Pieces Of Content

If you want the ability to hide your sidebar on a page-by-page basis, there are a few different methods that you can use.

First, you can do it with a plugin, which is what I recommend for most people because it’s free and simple. Or, you can also do it with your own code if that’s more your speed.

Check If Your Theme Offers Full-Width Templates First

Before you go searching for a third-party solution, many themes now let you remove your sidebar on a post-by-post basis with built-in functionality.

So – check for that before doing anything else. For example, GeneratePress, the theme that we use here at WPLift, lets you disable the sidebar for any content with the check of a box:

generatepress hide sidebar

Many other themes that are built to pair with page builders offer similar functionality.

Use A Free Plugin To Remove Your Sidebar On Certain Content

The absolute easiest way to remove your site’s sidebar on a page-by-page basis is with the free Fullwidth Templates for Any Theme & Page Builder plugin from Brainstorm Force, the makers of the popular Astra theme which Daan uses for EasyThemePacks.

This plugin basically adds a full-width template to any theme. There’s nothing to configure – just install and activate the plugin.

Then, you can use the Post Attributes or Page Attributes drop-down and select FW No Sidebar to create full-width content with no sidebar (the plugin also includes other templates that can hide your header and other content):

no sidebar template

And that’s all there is to it! Super simple, right?

Create Your Own Full-Width Template With Code

If you’re a masochist, or you just don’t like using plugins for some reason, you can also manually create your own full-width template to remove your sidebar on a page-by-page basis.

For most people, I really would just recommend sticking with the plugin above, so I’ll keep this tutorial pretty high-level:

edit pagep.php

  • Create a new file on your desktop called full-width.php
  • Copy the contents from page.php to the new full-width.php file
  • Add the following code snippet after the opening <?php tag

/*
Template Name: Full-width Template
*/

  • Find and delete this code snippet from the full-width.php file – <?php get_sidebar(); ?>
  • Upload full-width.php to your child theme’s folder via FTP

Then, you’ll be able to use the full-width template via the Page Attributes drop-down, just like you saw with the plugin.

You can also do something similar to create a full-width template for posts.

*Note, sometimes things get a little more complicated because your theme puts the get_sidebar() code in a different file (usually in the “template-parts” folder). If that’s the case, I really recommend just going with the plugin as it’s a lot simpler.

How To Remove WordPress Sidebar For Your Entire Site

Ok, let’s say that you really hate your WordPress site’s sidebar. You don’t just want to disable it on specific pages, you want to get rid of it on all your content.

In that case, you’re going to basically do what I showed you in the manual code method from above, but for the default template (that is, instead of creating a separate template that you apply on a page-by-page basis).

Like that method, this will require a little bit of code know-how if you want to get it done.

Step 1: Delete <?php get_sidebar(); ?>

To get started:

Then, you need to find and delete this code <?php get_sidebar(); ?>:

remove getsidebar

Then, repeat the process for other files that may include a sidebar. Common files would be index.php, page.php, etc.

Step 2: Fix CSS To Make Content Fullwidth

After the step above, your sidebar should be gone. However, your content will stick act as if there’s a sidebar when it comes to the layout, which can lead to some awkward situations like this:

weird layout

To fix that, you’ll need to use some custom CSS. Unfortunately, I can’t give you the exact code because it’s different for every theme.

But basically, you’ll want to make the width for the main content area to be 100%. For example, here’s what doing that looks like with the default Twenty Seventeen theme:

fix weird layout with no sidebar

And here’s the exact code snippet that I used:

.has-sidebar:not(.error404) #primary {
width: 100%;
}

If you’re struggling with how to figure out what CSS to use on your site, you might want to try a paid service like WP Kraken.

How To Show Different WordPress Sidebars For Different Content

Finally, maybe instead of removing your sidebar, you really just want to display different sidebars for different content.

For example, maybe you want some big, ad-filled sidebar for some content, and then a stripped down minimalist sidebar for others.

That’s totally possible to do. In fact, we wrote an entire post on the subject. If you want to learn more, check out our post on how to use different WordPress sidebars for different types of content.

You can also use this to show a blank sidebar (no widgets) for certain content, which can also kind of get you to the same place as these other methods.

Final Thoughts

For the absolute simplest way to remove your WordPress site’s sidebar, you can try deleting all of the widgets or you can use the free Fullwidth Templates for Any Theme & Page Builder plugin to get access to a full-width template that you can use on a post-by-post or page-by-page basis.

If you want to remove your sidebar sitewide or just prefer a more manual approach, you can also essentially just remove any mentions of <?php get_sidebar(); ?> from your theme’s files or create a custom template without this snippet, though you might need to add some custom CSS to clean things up afterward.

Have any other questions about how to remove or hide the WordPress sidebar? Let us know in the comments!

Wp-dd.com

WordPress Design, WordPress Development, cPanel Hosting, Web Design, Web Development, Graphic Design, Mobile Development, Search Engine Optimization (SEO) and more.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.