Support » Themes and Templates » Custom sidebars for category templates?

  • I’m trying to add a custom sidebar to my podcast category page @ I’m still very new to wordpress, and I’m catching on slowly. I’m thinking that I will need to edit functions.php and possibly category-3.php. Can someone please give me a thorough run down of what I need to do (hopefully without links to the codex).



Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    the first thing you need to do is to create the theme file that is going to define the ‘special’ sidebar. The easiest way of doing this would be to copy the current sidebar.php and rename it to (for example) new_sidebar.php

    next you need to alter this new_sidebar.php to fit your specific needs.

    now you need to make sure this new sidebar is linked to the specific category (category-3 or podcast in your case). There are two ways of doing this:

    1) if you already have a category-3.php file in your theme’s directory you only need to replace the

    <?php get_sidebar(); ?>

    code with this code :

    <?php include(TEMPLATEPATH."/new_sidebar.php"); ?>

    This is all.

    2) if your theme does not have a category-3.php file, you need to edit the category.php file and replace this code:

    <?php get_sidebar(); ?>

    with this code:

    <?php if(is_category('3')){include(TEMPLATEPATH."/new_sidebar.php");}else{get_sidebar();};?>

    I hope this helps you solve your problem.

    ok, I tried this and I got double the sidebar in my podcast category page.

    Can you show your code here? so that we can find the problem.

    This is from category-3.php

    <?php else : ?>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    	<?php endif; ?>
    <?php include(TEMPLATEPATH."/podcastsidebar.php"); ?>
    <?php get_sidebar('podcastsidebar.php'); ?>
    <?php get_footer(); ?>

    You know what, maybe I did something pretty stupid…was I supposed to change TEMPLATEPATH to the actual directory?

    oh and my podcastsidebar.php is an exact copy of sidebar.php if thats of any help.


    delete either this line:

    <?php include(TEMPLATEPATH."/podcastsidebar.php"); ?>

    or this line:

    <?php get_sidebar('podcastsidebar.php'); ?>

    because they both call for the same sidebar, so that’s why you get it twice.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom sidebars for category templates?’ is closed to new replies.