• Here is where I am at: I have installed widgets and everything works fine. I can get widgets to show up on the homepage and other pages, but I am trying to put different widgets on different sidebars on different pages. In sidebar.php I do two of these:

    <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('Sidebar 1') ) : else : ?>
    <?php endif; ?>

    One has ‘Sidebar 1’ the other ‘Sidebar 2’ and then in one of those one has is_home() the other has is_page(3)

    but all pages display sidebar 1 and sidebar 2 for some reason.

Viewing 5 replies - 1 through 5 (of 5 total)
  • have you checked your functions.php file?
    it should have the total number of dynamic sidebars in the brackets like so
    <?php if ( function_exists('register_sidebars') ) register_sidebars(2);?>

    oh and also in your code, it shouldn’t say dynamic_sidebar('Sidebar 1') it should just be dynamic_sidebar(1) or 2 obviously

    Thread Starter mtweldon

    (@mtweldon)

    K have that in the functions like that.

    I changed it to sidebar(1) and sidebar(2) but it still does the same thing.

    here is what I am basically doing in sidebar.php
    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>

    <?php /* If this is the creator page */ if ( is_page(3) ) { ?>
    <?php } ?>

    <?php endif; ?>
    <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(1) ) : else : ?>
    <?php /* If this is the frontpage */ if ( is_home()) { ?>
    <?php } ?>
    <?php endif; ?>

    *(‘Sidebar 1’) does the same thing as (1) I believe

    if they do the same i apologise.

    maybe try out the following:
    <?php if (function_exists('dynamic_sidebar')) {dynamic_sidebar(2); } ?>
    you dont need to end with and endif for this first one, or maybe try

    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar(2) ) : ?>

    fow which you need endif.
    change 1 and 2 appropriately. they’re just other ways of writing it.

    also, ive never tried having two dynamic sections in one sidebar.php so maybe thats what the problem is?

    maybe do you need the is_home before. so like this

    <?php
    if (is_home()) { if (function_exists('dynamic_sidebar')) {dynamic_sidebar(1);
    } elseif (is_page(3)) { if (function_exists('dynamic_sidebar')) {dynamic_sidebar(2);
    }?>

    not sure that you need anything else in there…

    try them out at let me know, sorry if it isnt a straight forward fix

    Thread Starter mtweldon

    (@mtweldon)

    If I wanted to use two different sidebar.php files would I just create sidebar2.php and then put in <?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>

    <?php /* If this is the creator page */ if ( is_page(3) ) { ?>
    <?php } ?> ?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Sidebar widgets in multiple sidebars’ is closed to new replies.