WordPress.org

Support

Support » Themes and Templates » How to widgetize two sidebars?

How to widgetize two sidebars?

  • Hi, I’m widget newbie and I have a very strange problem. I have to widgetize two sidebars. In functions.php I have:

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebars(2);
    ?>

    and in sidebar.php:

    <div id="side">
    	<div id="sideleft">
    	<ul>
    		<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>
                	...
            	<?php endif; ?>
        	</ul>
    	</div>
        <div id="sideright">
        	<ul>
        		<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2)) : else : ?>
    
            	<?php endif; ?>
            </ul>
    	</div>
    </div>

    Please, where can be problem? In other theme which I downloaded from internet is this code working 🙁

    Thanks a lot…

Viewing 5 replies - 1 through 5 (of 5 total)
  • nobody knows? 🙁 please help me

    try this code in the functions.php file

    <?php
    if ( function_exists('register_sidebar') )
    {
    register_sidebar(array('name'=>'Left Sidebar'));
    register_sidebar(array('name'=>'Right Sidebar'));
    }
    ?>

    and this in the sidebar – make sure to change it to ‘Right Sidebar’ in your second div

    <?php if ( !function_exists('dynamic_sidebar')
            || !dynamic_sidebar('Left Sidebar') ) : ?>
    <?php endif; ?>

    the beauty of this is that you can name your sidebars – makes for easier editing

    epicalex: Works great! Thanks, thanks, thanks, … 🙂

    I had the same problem as machi had previously. I later found the error is originated from space between closed bracket (i.e ‘)’) at the first line of the code.

    <?php if ( function_exists('register_sidebar') )
     register_sidebars(2); ?>

    Remove the space between both closed brackets and it should fix the problem.

    Remove the space between both closed brackets and it should fix the problem.

    PHP ignores whitespace, how can that make a difference? If I understood you correctly.

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