WordPress.org

Ready to get started?Download WordPress

Forums

Different Sidebars for different pages? (5 posts)

  1. kyle110
    Member
    Posted 5 years ago #

    Hi,

    Is there any way to have multiple sidebars showing different widgets for different pages?

    I see there is a drop down list which shows 'sidebar 1' so is it possible to do this, if so how?

    thanks
    Kyle

  2. moshu
    Member
    Posted 5 years ago #

    Actually, you are asking 2 [two] different questions.
    Part one: yes, you can have different sidebars, you just have to call them correctly into the Page template files... which means you need more than one Page template file (or a bunch of Conditional_Tags in it.
    (It was asked and answered even today here in the forum)

    Part two: Then, in order to be able to use widgets in all the sidebars, you need to "regsiter" them in the functions.php of the theme. Search for "multiple sidebars widgets" and you will find the code for it.

  3. kyle110
    Member
    Posted 5 years ago #

    Hi,

    So I have been able to sort out my multiple sidebars so that they can pe viewed in the drop down list under 'current widgets'

    HOWEVER I am having trouble calling these so that each different sidebar is displayed for each page.

    I have edited the page.php file so that instead of using >

    <?php get_sidebar(); ?>

    I am using >

    <?php
    if (is_page('13')) {
    
     include(TEMPLATEPATH . '/sidebar3.php');
    
    } elseif (is_page('10')) {
    
    include(TEMPLATEPATH . '/sidebar2.php');
    
    } else {
    
    include(TEMPLATEPATH . '/sidebar.php');
     }
     ?>

    this isnt working and its not throwing up any errors the right sidebars arent displayed for the right page this is the problem. Bit of a novice with PHP so any help much appreciated.

    thanks
    Kyle

  4. moshu
    Member
    Posted 5 years ago #

    I am not a coder either, and just looking at it (=no testing) it seems that it should work.

  5. fltseng
    Member
    Posted 5 years ago #

    Not being a coder myself either, I have however been working on the same issue for a day or two now. I'll copy-paste the code that works for me at the moment:

    <?php
    $post = $wp_query->post;
    
    if ( in_category('4')) {
    include ('sidebar-classes.php');
    } else if ( in_category('5')){
    include ('sidebar-kits.php');
    } else if ( in_category('0')){
    include ('sidebar.php');
    }
    ?>

    I can imagine it's the small differences that PHP ticks on, like how you've written elseif together instead of separate. Further than that, I cannot really provide any further assistance (PHP is foreign to me really), but I hope this code might help?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.