Wordpress How to: Hide sidebar on homepage or any page.
The sidebar is a very important part of a wordpress blog but sometimes you just don’t need it displayed in the Front Page of your Website. For example, You want to build a sales letter type of website and you will not be needing the sidebars on the front page but needs it on the other pages of the site. Read more to know how to do this:
Find index.php on your theme and open it and find the code below :
1 | <?php get_sidebar(); ?> |
Replace it with this :
1 2 3 | <?php if (!is_front_page()) { get_sidebar(); } ?> |
That’s it! The sidebar will no longer be included on your Wordpress Front Page but still be displayed on your other pages. The tag
is_front_page is built-in to wordpress and means the “front page” , the exclamation mark on it means not frontpage so basically it says “If the page is not the frontpage display sidebar”. Was that easy or what?!
Tell your stories on how you used this hack below :
Popularity: 32%
















































about 8 months ago
Dear Author fixmywpblog.com !
You have hit the mark. In it something is also I think, what is it good idea.
about 8 months ago
Thanks. You are welcome to look and see the site as it develops and hopefully a site that will teach others to fix their blogs by the information that you readers are contributing.
Site will be fully LIVE on January 27 2010. Stay tuned.
about 6 months ago
can we do that in a category.
for example, when i am in “Movies” category, can i hide sidebar?
about 6 months ago
Nope, can’t do that. You can only hide sidebar on pages. Lets say you created a page called Movies and you don’t want the sidebar there, just use the code and replace !is_front_page () with !is_page(‘Movies’) basically it says show sidebar if it is NOT page called Movies. There might be a way to tell sidebar that if it is on a particular category then hide.
about 6 months ago
thank you for your comment.