register_sidebar()函数注册一个单独的侧边栏区域和返回ID
<?php register_sidebar( array( 'name' => '侧边栏', 'id' => 'unique-sidebar-id', 'description' => '', 'class' => '', 'before_widget' => '<div class="s-con text-center">', 'after_widget' => '</div>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' ) ); ?>
参数
name – 侧边栏的名字(默认是 ‘Sidebar’ 加 数字 ID)
id – 侧边栏 ID,必须全部小写,不带空格(默认是一个自动递增的数字 ID)
description – 用来说明侧边栏是什么,在哪里显示的文字。会在小工具管理界面显示。(默认为空)
class – 分配到小工具 HTML输出中的CSS选择器名字(默认为空)
before_widget – 在每个小工具前面输出的 HTML代码(默认: ‘<li id=”%1$s” class=”widget %2$s”>’)
after_widget – 在每个小工具后面输出的 HTML代码(默认: “</li>”)
before_title – 在标题前输出的 HTML代码(默认: <h2 class=”widgettitle”>)
after_title – 在标题后输出的 HTML代码(默认:”</h2>”)