昨天发了一篇不同页面调用不同侧栏小工具的方法,《wp/wordpress调用侧边栏》,那么如何注册多个小工具侧栏工具呢?不多废话,上代码:

wp/wordpress如何注册页面侧栏,并在小工具里面显示-Qui-Note

直接在functions.php中加入注册代码:

// 注册 小工具 页面 侧栏模块
register_sidebar(array(
    'name'			=> '首页侧栏',
    'id'			=> 'widget_left_index',
    'before_widget'	=> '<section class="widget %2$s">', 
    'after_widget'	=> '</section>', 
    'before_title'	=> '<h3 class="widget-title">', 
    'after_title'	=> '</h3>' 
));
register_sidebar(array(
	'name'			=> '列表页侧栏',
	'id'			=> 'widget_left_list',
    'before_widget'	=> '<section class="widget %2$s">', 
    'after_widget'	=> '</section>', 
    'before_title'	=> '<h3 class="widget-title">', 
    'after_title'	=> '</h3>' 
));

register_sidebar(array(
	'name'			=> '文章页侧栏',
	'id'			=> 'widget_left_article',
    'before_widget'	=> '<section class="widget %2$s">', 
    'after_widget'	=> '</section>', 
    'before_title'	=> '<h3 class="widget-title">', 
    'after_title'	=> '</h3>' 
));

register_sidebar(array(
	'name'			=> '分类页侧栏',
	'id'			=> 'widget_left_tag',
    'before_widget'	=> '<section class="widget %2$s">', 
    'after_widget'	=> '</section>', 
    'before_title'	=> '<h3 class="widget-title">', 
    'after_title'	=> '</h3>' 
));