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

2 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.

Leave a Reply




 

Related Posts: