本文整理自网络,侵删。
register_sidebar()(创建侧边栏)
建立一个侧边栏,用来放置小工具。这个函数使用的时候请放在一个函数里,挂载到 “widgets_init” 钩子。
用法
register_sidebar( $args );
参数
$args
(字符串 | 数组)(可选)要创建的侧边栏的参数。
默认值:
$args = array( 'name' => __( 'Sidebar name', 'theme_text_domain' ), 'id' => 'unique-sidebar-id', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1" class="widget %2">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>' );
数组参数介绍:
- name:侧边栏名称
- id:侧边栏 ID,必须为小写,默认为递增的数组 ID
- description:侧边栏描述
- class:给其中的小工具的额外 class
- before_widget:里边的小工具的开头 Html 代码
- after_widget:里边的小工具的末尾的 Html 代码
- before_title:里边的小工具的标题的开头 Html 代码
- after_title:里边的小工具的标题的末尾的 Html 代码
例子
register_sidebar( array( 'name' => __( '右边的侧边栏' ), 'id' => 'sidebar-1', 'description' => __( '右侧边栏的小工具。' ), 'before_title' => '<h3 class="title">', 'after_title' => '</h3 class="title">', ));
其它
相关阅读 >>
基于vue.js与wordpress rest api构建单页应用详解
wordpress实现自带的侧边栏和自定义的侧边栏同时存在的方法
更多相关阅读请进入《wordpress》频道 >>