• Ok, i want to add custom sidebar to display on my index.php page. The second sidebar (which will be shown on index.php page) should be widgetized.

    I found several instructions on the net, managed to do it, and here’s how it goes:

    I insert the code in functions.php file

    <?php if ( function_exists ('register_sidebars')) {
        register_sidebars ('2');
    }

    I created a file sidebar-2.php and put the following code in it

    <?php if ( function_exists('dynamic_sidebar')&&dynamic_sidebar(2) ) : else : ?>
         <?php endif; ?>

    And eventually called that file from index.php with
    <?php get_sidebar(2) ?>

    And, instead of widgets, i see this message
    ??<??php if ( function_exists('dynamic_sidebar')&&dynamic_sidebar(2) ) : else : ?> <??php endif; ?>

    What might be the problem?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Use the Custom sidebars plugin, you will need no coding.

    Try this:

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

    Not sure why you see all that crazy stuff. If you copied the code directly then it may not have been encoded right on the page so it wont parse.

    You really don’t need a second sidebar.php file. You can just put both sidebars in the sidebar.php file that came with your theme and wrap them in <div> tags.

    For example:

    <div id="sidebar-left">
    </div><!--sidebar-left-->
    <div id="sidebar-right">
    </div><!--sidebar-right-->

    then style them in css

    #sidebar-left {float:left; width:XXXpx;}
    #sidebar-right {float:right; width:XXXpx;}

    if your content is centered then you would want to add your sidebar function at the top of your index file just below the <?php get_header() ?> function and margin your content over to allow for the left sidebar.

    Good luck.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom sidebars problem?’ is closed to new replies.