[wp-hackers] Pagination: How to display sidebar content on front page only?

Peter Westwood peter.westwood at ftwr.co.uk
Wed Jan 13 07:33:04 UTC 2010


On 12 Jan 2010, at 22:36, RePost wrote:
>
> Thanks, all. I used your suggestions, and this is what worked for me:
>
> <?php
> if ( is_front_page() && !is_paged() )
> include("sidebar-index.php");
> else
> include("sidebar.php");
> ?>
>

An improvement on this which makes it much more friendly if you  
include in a released theme (and enabled child theme overload of  
template files) is to use get_sidebar();

<?php
if ( is_front_page() && !is_paged() )
     get_sidebar('index');
else
     get_sidebar();
?>

This allows for named sidebars as shown about and will also search  
child theme first and fallback to default theme sidebar.php if no file  
is found to include.

Cheers

Peter
-- 
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5



More information about the wp-hackers mailing list