WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get_sidebar by checking for the the category ... (2 posts)

  1. rasmuscarlsen
    Member
    Posted 4 years ago #

    Hi all,

    Sorry for my poor php. Here it comes;

    I like to use a different sidebar for a specific category (and maybe antoher sidebar for another category).

    As I understand its something lige this:

    <?php
    if ( in_category('category-a') ) {
    	<?php get_sidebar('category-a'); ?>;
    } elseif ( in_category('all-other-categorys') ) {
    	<?php get_sidebar('sidebar'); ?>;
    } else {
    
    }
    ?>

    But its not the way to do it ...

    Guess its basic php - I gotter learn some day ;-)

    thanks

    rasmus

  2. rasmuscarlsen
    Member
    Posted 4 years ago #

    got it ...

    its as simple as this:

    <?php
    if ( in_category('39') ) :
        get_sidebar('two'); //this will include sidebar-two.php
    else :
        get_sidebar();
    endif;
    ?>

    Sorry for sleepy eyes. ;-(

    rasmus

Topic Closed

This topic has been closed to new replies.

About this Topic