Search code examples
wordpresswordpress-themingsidebar

Adding a second Wordpress widget


I'm having difficulty with setting up a second sidebar for my Wordpress theme.

Here's the code for function.php:

<?php
if(function_exists('register_sidebar')){
    register_sidebar(array(
        'before_widget'=>'<li>',
        'after_widget'=>'</li>',
        'before_title'=>'<h2>',
        'after_title'=>'</h2>',
    ))
;
}
?>
<?php
if(function_exists('register_sidebar')){
    register_sidebar('home'array(
        'before_widget'=>'<li>',
        'after_widget'=>'</li>',
        'before_title'=>'<h2>',
        'after_title'=>'</h2>',
    ))
;
}
?>

This is the error I'm receiving when I try to access the widget options page in admin:

Parse error: syntax error, unexpected T_ARRAY in C:\xampp\htdocs\tlc\wp-content\themes\tlc\functions.php on line 14


Solution

  • to give it a name you use this syntax

     register_sidebar(array(
      'name' => 'RightSideBar',
      'description' => 'Widgets in this area will be shown on the right-hand side.',
      'before_title' => '<h1>',
      'after_title' => '</h1>'
    ));
    

    not what you wrote

    see this for more info http://codex.wordpress.org/Function_Reference/register_sidebar