Need help removing sidebar on pages

I use a 3 column site with sidebar left, sidebar right and content center.

I have multiple pages and would like to remove the right sidebar and allow the content to stretch to the right where the sidebar used to be.

My Home page is fine with 3 columns, I just want to apply this to other pages.

I am not very familiar with PHP code and am not sure which file needs to be hacked.

Any help would be appreciated.

Let me know if you need to see any file code.


Play around with the css file for those selected pages,

.right {
display: none;

.content {
width: 100% ;


or just create a condition which removes “right” from the html flow, or similar, thats what I did.

I am using a WP blog template that has only one CSS file.

I don’t know if this will work as it would delete the sidebar from all pages.

I want the Home page to be 3 column but other pages to be 2 column.

From what I have seen in other dialogues, this requires PHP code.

I just don’t understand what the proper code would be, what file it goes in, and where to place it.

Thanks for responding but I don’t feel CSS is the answer to my problem.

Sorry man, I’m no WP hack, the only thing I can think of is you try asking on dedicated WP forums.

I’m out.

with the $_SERVER vars you could check if you are at index.php and if it does not have a query string at the end you know you are home and display the “right” column.

If there is a query string, this is a posting and don’t dislay the “right” column.

I’m not sure if the center column has adjustable width to fill in where the right column was but you can override the style sheet by re-declaring the css width of the center column if the query string is found.

There are some conditional tags in WP.

The is_home() can be used to check whether the loading page is home page or not. And as far as I know there should be two files in the theme folder called something (left-sidebar.php and right-sidebar.php) included in the index.php file. So check if the page is home page then include right-sidebar.php otherwise do not include it.

    include "right-sidebar.php";

What I would do is use a body ID.

<body id="<?php if ( is_home() ) { ?>home<?php } else { ?>other<?php } ?>">

Then this will make it:

<body id=“home”> on the home page and <body id=“other”> on all other pages.

The name(s) “home” and “other” can be changed.

Next you will need to go through the theme files (page, single, search, 404, archive and any others) and remove the call to the sidebar you want to remove.

Looks something like this:

<?php get_sidebar(); ?>

Then in your .css find the styles in question and add the #home body ID to them. Then copy the same styles and paste them in the same .css file change the body ID from #home to #other and adjust them to meet the needs of the other pages.

#home #element{}
#other #element{}

I can’t give more details as I have not seen your site. Post a link and I will try to be more helpful with the .css edits. :slight_smile: