Search code examples
wordpresstemplatescategoriessidebar

How to tell Wordpress category page to call specific sidebar


I am trying to pull in a styled sidebar specific to the category. I have the following code which works, but it is pulling in BOTH my new sidebar and the default. What am I doing wrong here?

From category.php

<?php get_sidebar();
if ( in_category('39') ) {
include(TEMPLATEPATH . '/sidebar2.php');

} else {
include(TEMPLATEPATH . '/sidebar.php');

}
?>
<?php get_footer(); ?>

Solution

  • Because you're calling sidebar twice; do this:

    <?php
    
    if ( in_category('39') ) {
    include(TEMPLATEPATH . '/sidebar2.php');
    
    } else {
    include(TEMPLATEPATH . '/sidebar.php');
    
    }
    ?>