Using Conditional Tags should get you what you want…
Include these in your sidebar template and use, say
if(is_home()){ stick your code here }
if you want something just to display on the front page (though the help page seems to suggest this is handled differently in v2.1 but I haven’t really looked into it)…
Conditional tags work. Or, you can do what I do. edit the general-template.php and replace get_sidebar what I’ve pasted in below.
In your template, call get_sidebar with the name of your sidebar file — for example: get_sidebar(‘my-sidebar’). It defaults to “sidebar” so there’s no impact if you don’t include the file name.
——–
function get_sidebar($sidebar="sidebar") {
if ( file_exists( TEMPLATEPATH . '/' . $sidebar . '.php') )
load_template( TEMPLATEPATH . '/'. $sidebar . '.php');
else
load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
}
Editing the general-template.php file (in the wp-includes folder) — replacing get_sidebar with the code offered by jabecker — worked great for me. Thanks jabecker!!
I noticed that the line
do_action( 'get_sidebar' );
is missing from what they offer. Not sure if this matters but I put it in and the function works as described.
So you should have
function get_sidebar($sidebar="sidebar") {
do_action( 'get_sidebar' );
if ( file_exists( TEMPLATEPATH . '/' . $sidebar . '.php') )
load_template( TEMPLATEPATH . '/'. $sidebar . '.php');
else
load_template( ABSPATH . 'wp-content/themes/default/sidebar.php');
}
This modification can do a lot of good work (I think) because you can do the same for get_header().
Just an update:
It’s not necessary to edit the general-template.php file.
Just replace
<?php get_header(); ?>
with
<?php include(TEMPLATEPATH."/whatever-header-file-you-want.php"); ?>
and be sure to save the whatever-header-file-you-want.php file in the theme folder with all the other theme files, including the original header.php file.
You can do the same with sidebar files.
Just replace
<?php get_sidebar(); ?>
with
<?php include(TEMPLATEPATH."/whatever-sidebar-file-you-want.php"); ?>
and be sure to save the whatever-sidebar-file-you-want.php file in the theme folder with all the other theme files, including the original sidebar.php file.