Sidebar links for different pages

Hey all i am wondering what i need to add in order to have a different sidebar for a set page?

I created a category for the page (called PatientEdu):

Read More

patcat

And made sure the page was linked to the category:

patcat2

But it still seems to be using the other category sidebar (Which i also do not know where its at)?

parcat3

So any help would be great!

UPDATE

My current sidebar.php code is this:

<?php if (is_active_sidebar('default-sidebar')) : ?>
<div id="sidebar">
    <h2>Default Sidebar</h2>
    <?php dynamic_sidebar('default-sidebar'); ?>    
</div>
<?php endif; ?>

and the function code:

function

update 2

Looks like its using the single.php page to populate the sidebar?

<?php if (have_posts()) : ?>                        
    <div id="sidebar">
       <h3><?php echo get_cat_name(CAT_DOCTORS); ?></h3>
           <ul class="info-list">
             <?php while (have_posts()) : the_post(); ?>
              <li <?php if ($post_id == get_the_ID()) {echo 'class="active"';} ?>>
               <a href="<?php the_permalink(); ?>">
                 <span><?php the_title(); ?></span>
               </a>
             </li>
            <?php endwhile; ?>
           </ul>
   </div>
<?php endif; ?>

Related posts

Leave a Reply

2 comments

  1. Register a new sidebar by pasting this into your theme’s functions.php file:

    register_sidebars( 'id' => 'patientedu' );
    

    Create a file called sidebar-patientedu.php and paste the following into it:

    <?php if (is_active_sidebar('patientedu')) : ?>
    <div id="sidebar">
        <h2>PatientEdu Sidebar</h2>
        <?php dynamic_sidebar('patientedu'); ?>    
    </div>
    <?php endif; ?>
    

    Then paste this whereever you want your sidebar to show up:

    <?php get_sidebar('patientedu'); ?>
    
  2. First, WordPress automatically creates a sidebar for your template if one is not defined (by creating a sidebar.php in your theme).

    Secondly, you can register multiple sidebars by using register_sidebars in your functions.php file.

    The template function, get_sidebar, accepts a parameter, $name, which determines which sidebar file to get. For example, if you have a file in your theme folder called sidebar-doctors.php, you can call <?php get_sidebar('doctors'); ?> in your theme and get the doctors sidebar.

    You can use these techniques together to build a different sidebar for different template pages.

    Or! You can go one step further and add the following code and make a sidebar-<cat_slug>.php for each category. If there isn’t a php file with that name, WordPress will default to its own sidebar.php

    <?php
    if (is_category( ))
    {
        $cat = get_query_var('cat');
        $yourcat = get_category ($cat);
        get_sidebar($yourcat->slug);
    }
    ?>
    

    I hope this helps, and that I didn’t completely miss the mark on your question.