WordPress.org

Ready to get started?Download WordPress

Forums

two sidebars? (4 posts)

  1. kthxbai2u
    Member
    Posted 4 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    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).

  3. kthxbai2u
    Member
    Posted 4 years ago #

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

  4. kthxbai2u
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic