Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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):

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; ?>
share|improve this question
    
Still looking for a solution. –  StealthRT Nov 27 '12 at 13:28
add comment

2 Answers 2

up vote 1 down vote accepted

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'); ?>
share|improve this answer
    
Awesome, thanks for the help! –  StealthRT Nov 27 '12 at 15:01
add comment

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.

share|improve this answer
    
Take a look at my updated OP and see if what you said above still apply. –  StealthRT Nov 26 '12 at 21:17
    
Still looking for a solution –  StealthRT Nov 27 '12 at 13:27
    
You're off to a good start with your functions.php file and with your sidebar.php. Where you're checking if (is_active_sidebar('default-sidebar')) of course change "default-sidebar" to whatever you need to like "logos-sidebar". About your single.php, I would comment out the code inside div#sidebar and put in the snippet I wrote in my answer. –  Alex Lane Nov 27 '12 at 14:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.