添加第二个Wordpress小部件

时间:2010-08-30 18:22:47

标签: wordpress wordpress-theming sidebar

我在设置Wordpress主题的第二个侧边栏时遇到了困难。

这是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>',
    ))
;
}
?>

当我尝试访问admin:

中的窗口小部件选项页面时,这是我收到的错误
  

解析错误:语法错误,意外   T_ARRAY in   C:\ XAMPP \ htdocs中\ TLC \可湿性粉剂内容\主题\ TLC \的functions.php   第14行

1 个答案:

答案 0 :(得分:3)

给它命名,你使用这种语法

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

不是你写的

了解更多信息 http://codex.wordpress.org/Function_Reference/register_sidebar

相关问题