Deleting or Hiding the Sidebar in WordPress

Image representing WordPress as depicted in Cr...

Image via CrunchBase

Many times you’ll add a plugin to your WordPress blog that has to be placed on it’s own page. While most these plugins have the instructions on how to create the extra page to place the plugin on, they don’t give you any extra help. I recently helped a friend that had one such plugin and thought it would look great if it had a larger area to be seen, so he wanted to delete his right sidebar from just that page.

Here’s how to delete your sidebar from an extra page on your WordPress blog:
When creating the new page there’s a dropdown on the right hand side asking you which page template you’d like to use, problem is if your site uses sidebars the templates probably have sidebars also. So lets create our own WordPress template.

Either using FTP or the original download of your current theme, download or copy the page.php file to another directory. Open the copy of page.php (notepad will work), on the very first line hit enter to drop down the code that’s there a couple lines and add this piece of code:

<?php
/*
Template Name: MyTemplate
*/
?>

You can name the template (Template Name: MyTemplate) anything you’d like. Then scroll down toward the bottom of the page and look for something along the lines of:

<?php get_sidebar(); ?>

It may actually say something like rightsidebar or something, just look for sidebar in the name and delete the entire line (like the line shown above).

Now “save as” and name the file anything you’d like (MyTemplate.php) always end it in .php Now upload it to your theme directory, this has to be the directory that you are currently using as your theme (i.e. /wp-content/themes/{theme name}). once it’s uploaded go back to either the page you already created or create a new page, on the right sidebar under Attributes -> Template use the dropdown list to choose the template that you just created. Save and preview. Your sidebar should be hidden.

Technorati Tags: , , , , ,

     

2 Comments to “Deleting or Hiding the Sidebar in WordPress”

  1. @JesseLuna 28 August 2010 at 6:50 pm #

    Perfect! Just what I was looking for. I have a WP page that needs all the “real estate” available. Thanks!

  2. Psychic Lucy 17 April 2012 at 8:56 pm #

    Thanks so much, it also works for the footer too! Do you know how I can replace or even remove the header on a single page? I tried using this method but it got rid of the width formatting of the page which I didn’t want.

    Thanks for any advice!


Leave a Reply