WordPress.org

Ready to get started?Download WordPress

Forums

Custom sidebars for category templates? (6 posts)

  1. AntonioP
    Member
    Posted 6 years ago #

    I'm trying to add a custom sidebar to my podcast category page @ http://www.atriskstoriesofhope.com/category/podcast 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).

    Thanks

    Antonio

  2. rmk80
    Member
    Posted 6 years ago #

    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.

  3. AntonioP
    Member
    Posted 6 years ago #

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

    http://www.atriskstoriesofhope.com/wordpress/category/podcast

  4. muthukswamy
    Member
    Posted 6 years ago #

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

  5. AntonioP
    Member
    Posted 6 years ago #

    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; ?>
    
    	</div>
    <?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.

    Antonio

  6. rmk80
    Member
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic