Support » Fixing WordPress » Have multiple widgetized sidebars for my theme but not calling them correctly

  • Resolved semidivine

    (@semidivine)


    What am I doing wrong?

    I have this code in my functions.php:

    if ( function_exists('register_sidebar') )
    {
    register_sidebar(array('name'=>'twitter'));
    register_sidebar(array('name'=>'left'));
    register_sidebar(array('name'=>'right'));
    }

    and I am able to add widgets to sidebars “twitter”, “left” and “right” in the admin. In my templates I am calling the different sidebars in different locations using this (as an example):

    <?php get_sidebar('right'); ?>

    It’s not working! How do I do it correctly?

    Thanks!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Try:

    if ( function_exists('register_sidebar') ) {
    register_sidebar(array('name'=>'twitter', 'id=>'twitter'));
    register_sidebar(array('name'=>'left', id'=>'left'));
    register_sidebar(array('name'=>'right', 'id'=>'right'));
    }

    Ah thanks but that didn’t work. With my old code the first sidebar worked (twitter) but no other. With your code even the twitter widget didn’t show up.

    How are you calling your sidebars?

    <?php get_sidebar('twitter'); ?>

    or

    <?php get_sidebar('left'); ?>

    or

    <?php get_sidebar('right'); ?>

    in different templates.

    And the sidebar files are called?

    Ah good question… I wasn’t sure what to do about that and whether to put some code in the sidebar template itself.

    For now they are called sidebar.php, sidebar2.php and sidebar3.php.

    Sorry, that wasn’t clear… I have code in the sidebar templates, but nothing to distinguish between them.

    I have:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    		...
    <?php endif; ?>

    Anybody else? I still have not been able to get this to work, and searching through the forums have not found an answer…

    Try naming your sidebar files sidebar-twitter.php, sidebar-left.php and sidebar-right.php.

    That did it!! Thanks so much.
    I wish they had documentation about this…
    Have a great day.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Have multiple widgetized sidebars for my theme but not calling them correctly’ is closed to new replies.