Support » Fixing WordPress » display different sidebar depending on which category you select.

  • I ma not a php guy, but I have been trying to get this to work with no luck. I have created a different sidebar for the baseball category and I have edited my category.php to try and make the baseball sidebar appear when the baseball category is selected. Here is the category code I have been trying to get working

    <?php get_header(); ?>
    <?php if ( in_category(’26’) ) { ?>
    <?php include (‘pagesidebar_baseball.php’); ?>
    <?php } else { ?>
    <?php get_sidebar(); ?>

    <div class=”middle”>

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2>
    <p><small><?php the_time(‘F jS, Y’) ?> <?php the_author() ?></small> Posted in <?php the_category(‘, ‘) ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?> <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php if(function_exists(‘the_views’)) { the_views(); } ?></p>

    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    <!– AddThis Bookmark Post Button BEGIN –>
    <?php echo “<div class=\”addthis\”><img src=\”\” width=\”125\” height=\”16\” border=\”0\” alt=\”AddThis Social Bookmark Button\” /></div>”; ?>
    <!– AddThis Bookmark Post Button END –>

    <div class=”br”>
    <?php endwhile; ?>

    <div class=”alignleft”><?php next_posts_link(‘« Previous Entries’) ?></div>
    <div class=”alignright”><?php previous_posts_link(‘Next Entries »’) ?></div>

    <?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 get_sidebar(); ?>

    <?php get_footer(); ?>

    I am doing something wrong and I am very confused.
    Can a php master please step in and point me in the right direction?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display different sidebar depending on which category you select.’ is closed to new replies.