WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Have multiple widgetized sidebars for my theme but not calling them correctly (11 posts)

  1. semidivine
    Member
    Posted 3 years ago #

    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!!

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    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'));
    }
  3. semidivine
    Member
    Posted 3 years ago #

    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.

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    How are you calling your sidebars?

  5. semidivine
    Member
    Posted 3 years ago #

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

    or

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

    or

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

    in different templates.

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    And the sidebar files are called?

  7. semidivine
    Member
    Posted 3 years ago #

    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.

  8. semidivine
    Member
    Posted 3 years ago #

    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; ?>
  9. semidivine
    Member
    Posted 3 years ago #

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

  10. esmi
    Forum Moderator
    Posted 3 years ago #

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

  11. semidivine
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic