WordPress.org

Ready to get started?Download WordPress

Forums

How to get all my sidebars to work not just one. (7 posts)

  1. xavier039
    Member
    Posted 6 years ago #

    I would like to add more than one sidebar. I have my functions.php script to register 4 sidebars:
    PHP Code:

    <?php
    <code></code>if ( function_exists('register_sidebar') )
    register_sidebar(array('name'=>'sidebar1',
    'before_widget' => '<div id="%1$s" class="side-c %2$s">', // Removes <li>
    'after_widget' => '</div>', // Removes </li>
    'before_title' => '<h3>', // Replaces <h2>
    'after_title' => '</h3>', // Replaces </h2>
    ));
    register_sidebar(array('name'=>'sidebar2',
    'before_widget' => '<div id="%1$s" class="side-c %2$s">', // Removes <li>
    'after_widget' => '</div>', // Removes </li>
    'before_title' => '<h3>', // Replaces <h2>
    'after_title' => '</h3>', // Replaces </h2>
    ));
    register_sidebar(array('name'=>'sidebar3',
    'before_widget' => '<div id="%1$s" class="side-c %2$s">', // Removes <li>
    'after_widget' => '</div>', // Removes </li>
    'before_title' => '<h3>', // Replaces <h2>
    'after_title' => '</h3>', // Replaces </h2>
    ));
    register_sidebar(array('name'=>'sidebar4',
    'before_widget' => '<div id="%1$s" class="side-c %2$s">', // Removes <li>
    'after_widget' => '</div>', // Removes </li>
    'before_title' => '<h3>', // Replaces <h2>
    'after_title' => '</h3>', // Replaces </h2>
    ));
    ?>

    My sidebar.php script is set for 4 sidebars as well:
    PHP Code:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar1') ) : ?>
    <?php endif; ?>
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar2') ) : ?>
    <?php endif; ?>
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar3') ) : ?>
    <?php endif; ?>
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar4') ) : ?>
    <?php endif; ?>

    I have my sidebars set in the right place. I placed my
    PHP Code:
    <?php get_sidebar(); ?>
    in the right places. However when I go to place the 4 widgets all 4 widgets only appear in the first sidebar while the other sidebars remain blank. Any ideas?

  2. moshu
    Member
    Posted 6 years ago #

    And how do you call the sidebar2 and sidebar3 and sidebar4 into your template files???

  3. xavier039
    Member
    Posted 6 years ago #

    I used <?php get_sidebar(); ?> to call each of them. I called sidebar in the header then I wanted to call the next three in the footer. Am I calling them wrong? Is it suppose to be <?php get_sidebar2(); ?>
    <?php get_sidebar3(); ?> and so on? Do I still only need just sidebar.php and not sidebar2.php?

  4. moshu
    Member
    Posted 6 years ago #

    Am I calling them wrong?
    Yes.

    Is it suppose to be <?php get_sidebar2(); ?>
    <?php get_sidebar3(); ?> and so on?

    No!

    You should have searched a bit the forums how to call a non-standard template file...
    <?php include (TEMPLATEPATH . '/yourfile-name.php'); ?>

    Use it as it is, change only the file name.
    Assuming you have 3 more files in the theme folder, named sidebar2.php, sidebar3.php and sidebar4.php...
    If you don't ---

  5. moshu
    Member
    Posted 6 years ago #

    Just out of curiousity: do you have a theme that can accomodate 4 sidebars? I'd like to see it, if it's possible.

  6. xavier039
    Member
    Posted 6 years ago #

    Got it! Thank you so much. I didn't know about the ability to call a non-standard template file. Once you said that I was golden. 100 times easier than what anybody else has written up. I actually have 10 sidebars. It is just the whole left side of the post is a sidebar. Then on the right side of the post I have 9 boxes that I made each into their own sidebar. Basically I wanted unique boxes to the right of my posts so I made each their own sidebar. http://www.joystiq.com has the same layout I use check out their's for an example.

  7. deanhatescoffee
    Member
    Posted 6 years ago #

    @ moshu - My Fight theme has 4 sidebars; well, 1 on the side, 3 on the bottom, but they're all widgetized and functioning.

Topic Closed

This topic has been closed to new replies.

About this Topic