WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Trouble Adding a Second Sidebar – HELP DESPERATELY NEEDED!

[Resolved] Trouble Adding a Second Sidebar – HELP DESPERATELY NEEDED!

  • Hello,

    I’m attempting design my own WordPress theme for my business using Dreamweaver CS5 and have run into trouble implementing more than one sidebar. Here’s the story: I currently have a header, a right sidebar that contains a couple of widgets (not in a list), an unordered list on the left of the page that link to different HTML pages within the site (about me, what I do, etc.), and a footer. The “body” in the center of the page will consist of blog entries. However, for widget and appearance purposes, I would like the div on the left of the page that contains the HTML links to be a separate sidebar. I have literally spent hours on the web trying to find some guidance, but something isn’t clicking.

    I am an absolute novice with PHP, but understand HTML and CSS very well. I currently have the following PHP code in my functions.php file that I made in the wp-content/themes/mytheme folder:

    [please mark the code using backticks or the ‘code’ button]

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array('name'=>'sidebar1',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    register_sidebar(array('name'=>'sidebar2',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h4>',
    'after_title' => '</h4>',
    ));
    ?>

    I also put the following code into my sidebar.php file in the same folder:

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

    I understand that the code required in the index.php file needs to be
    <?php get_sidebar(); ?> in order to call the specific sidebar that contains the widgets (in my case, the right sidebar), but what code should I use to call my left sidebar? Should I rename the sidebar.php file to sidebar1.php and have a second one called sidebar2.php for the left sidebar (even though I tried this and it didn’t work). For some reason WordPress does not recognize <?php get_sidebar1(); ?> or <?php get_sidebar2(); ?> when I place these strings where they’re seemingly supposed to be in index.php.

    I have tried almost every combination I can think of and can’t figure out what I’m doing wrong. Any help will be greatly appreciated!!
    Thanks!!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Trouble Adding a Second Sidebar – HELP DESPERATELY NEEDED!’ is closed to new replies.
Skip to toolbar