WordPress.org

Support

two sidebars?

  • First, here is the site I am questioning about:
    kthxbai2u.com

    If I wanted another sidebar on the left, could I just add it in the template code and it will automatically allow me to add widgets to it?

    I was just going to resize some divs and float another div left… Would that work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    @esmi

    Forum Moderator

    If you want different sidebar content, you’d need to create another sidebar template file. Try copying sidebar.php and renaming the copy sidebar-two.php. You can then call this new sidebar using <?php get_sidebar('two');?> in your template(s).

    oh ok I will give it a try and post my results! Thanks for the nudge in the right direction!

    Well, you helped me get another sidebar… thanks!

    but now I am wondering how I would go about duplicating the dynamic sidebar to make a second (seperate) sidebar?

    Anyone happen to know where the function “dynamic_sidebar” is? I would like to clone it 🙂

    <<EDIT>>

    Ok, so I figured it out… I copied sidebar into a new file, “sidebar-left.php”

    Next I edited the newly duplicated sidebar-left.php (from /wp-content/themes/your_theme/) and changed the line <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    to
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(2) ) : ?>

    Next, I opened functions.php (again, from /wp-content/themes/your_theme/)

    I cloned a section of code (as shown below) `if ( function_exists(‘register_sidebar’) ){
    register_sidebar(array(
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,
    ));
    }

    if ( function_exists(‘register_sidebar’) ){
    register_sidebar(2);
    }`

    Next you edit page.php and index.php and right after <?php get_header; ?> you add in the following: <?php include(TEMPLATEPATH . '/sidebar-left.php'); ?>

    Now all you need to do is customize sidebar-left.php and also drag/drop dynamic widgets to sidebar 2!

    Full tutorial at kthxbai2u.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘two sidebars?’ is closed to new replies.
Skip to toolbar