Free Wordpress Help | Wordpress Theme Customizations - Removing The Sidebar Altogether

Ask me a question at the Wordpress Ninja Forum

 

Wordpress Theme Customizations - Removing The Sidebar Altogether

Posted on August 12, 2008
Filed Under Wordpress Solutions |

Hi everyone, almost forgot to add this important frequently asked question about Wordpress Theme layouts - how do i remove the sidebar altogether so it is just a single-column, no-sidebar theme. Maybe you found a great SEO optimized Wordpress theme but you don’t want a sidebar?

Here’s what we need to do.

First step is to delete the sidebar ‘include’ code from every page that references it. The typical pages are all located in wp-content/themes/<your theme name>/ and are as follows

  • index.php
  • page.php
  • search.php
  • archive.php
  • single.php

A good way to find out for sure to be guaranteed of the sidebar not popping up somewhere where its not is to do a search in windows through each of those file for the following string

<?php get_sidebar();?>

NB: when doing a standard Windows file search (search string within files), you may need to force windows to include some file types - if you know for a fact that a search string exists within a file but the search does not find it then check out this article.

Upon removing the sidebar code from all files where it appears you will find that there will be no sidebar anymore in your theme but now your site layout will look all wrong because the size of the ‘content’ column will be too small and not centered.

To fix this you need to then go into the style.css file and expand the width of the content container to the full size of the page container, encompassing the blank space that the sidebar used to take up e.g. #container may have width of 960 pixels, but the #content container has width of 460 pixels. Change the #content width to be 960px and check padding and margins don’t blow the size out more than this - see my previous post on layouts for more info on this.

That’s all there is to it, you now have a single-column theme, which consists of a header, main body and footer and no sidebar.

Comments

16 Responses to “Wordpress Theme Customizations - Removing The Sidebar Altogether”

  1. Jay on September 13th, 2008 9:27 pm

    great article. how about removing the sidebar on one particular page? specifically, I’m using andreas’ 1024px theme and the page I want to remove it from won’t be listed in the table of contents.

  2. WPNinja on September 14th, 2008 12:01 am

    Jay,

    you could use a conditional statement like this in the page.php file:

    < ?php if ( !( is_page('xx') ) ) { ?>

    < ?php get_sidebar(); ?>

    < ?php } ?>

    This code should be placed surrounding the existing sidebar include statement (e.g. < ?php get_sidebar(); ?>) and change the xx to be your page ID that you dont want the sidebar for. You can find the page ID by hovering over the page link in Admin>Manage Pages and checking the url at the bottom of the browser - the page ID is the last number of the url.

    This code basically says ‘if this page being loaded is NOT page xx then DO include the sidebar’.

    cheers,

    Paul.

  3. Matthew on December 3rd, 2008 11:02 pm

    Yes, but what about after using that code, there is still a spacer where the sidebar used to be. How do I remove that space on only that one page which was excluded from displaying the sidebar?

  4. Me on March 1st, 2009 7:45 pm

    That’s cool!

  5. Elliott Goodwin on June 24th, 2009 9:06 pm

    @Paul the !(is_page… thing was exactly what I was looking for. Thank you!

  6. WPNinja on June 26th, 2009 1:52 am

    No problem :)

  7. Mel on June 29th, 2009 12:23 am

    Hello!

    I made this all suggestions but nothing happen…

  8. Wordpress Theme Customizations – Removing The Sidebar Altogether | Wordpress Ninja on August 4th, 2009 2:16 am

    [...] Wordpress Theme Customizations – Removing The Sidebar Altogether | Wordpress Ninja Comments0 Leave a Reply Click here to cancel [...]

  9. nick on October 8th, 2009 12:26 am

    I have the same question “Yes, but what about after using that code, there is still a spacer where the sidebar used to be. How do I remove that space on only that one page which was excluded from displaying the sidebar?” adding— i want to expand the size of my content in that certain page.

    Thanks

  10. dieseltech on October 9th, 2009 2:56 pm

    What if I have a theme with 2 sidebars and I want eliminate one of them? Seems to me that this fix will remove both of them.

    I love the theme - just only want one sidebar.

    dt

  11. walkingcomplete on November 12th, 2009 7:35 pm

    I have the same question… how to address the spacer or enlarge the column width only on the page with the custom template.

  12. JJ Bright on December 17th, 2009 6:27 pm

    Wow!
    Great instructions! Fantastic. Thank you so much.

    Janet
    themigrainediet.com

  13. Ahmedabad Ninja on December 19th, 2009 10:26 pm

    hey VVP ninja u have given me a exact solution well u r from VVP Engg Rajkot??

    me From SCET surat

  14. Matt on March 13th, 2010 9:20 pm

    Fantastic article - easy to follow and EXACTLY what I needed - Thank you =0)

  15. Dollar Items on March 29th, 2010 12:37 pm

    In the face before you, I really saints on earth if there is doubt; And now, I finally believed!
    Alloying golden ring Alloying jewelry sets Alloying jewelry sets with oil palting

  16. ed hardy sale on May 3rd, 2010 2:30 am

    Thank you for the informatione

Leave a Reply




 

Related Posts: