Wordpress Tips : Show sidebar only on homepage

Posted in Tech

I’ve come across many people who want to display their sidebars only on the homepage and not on individual posts & pages. You need to add just two lines of code to achieve this.

Go to Dashboard >> Appearance >> Editor >> Sidebar (sidebar.php)

Add the following code as the first line

<?php if ( is_front_page() ) { ?>

… and the following one as the last line of sidebar.php

<?php } ?>

Conversely, if you want to show the sidebar on all pages & posts except the home page, add the following as the first and last lines respectively.

<?php if ( !is_front_page() ) { ?>

<?php } ?>

Thats all you need to make your sidebar visibility selective, i.e. on or off the homepage.


 
Posted by Maneel   @   30 October 2009

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

1 Comments

Comments
Nov 2, 2009
10:37 am
#1 Amar :

Thanks for this handy tip :)

Leave a Comment

Name

Email

Website

Previous Post
«
Next Post
»
Powered by Wordpress   |   Lunated Sponsored by Azmovingusa.com