register_sidebars()批量注册并创建侧边栏

目录

描述

Creates multiple Sidebars.

Registers one or more sidebars to be used in the current theme. Most themes have only one sidebar. For this reason, the number parameter is optional and defaults to one.

The args array parameter can contain a 'name' which will be prepended to the sidebar number if there is more than one sidebar. If no name is specified, 'Sidebar' is used.

register_sidebars() 描述

用法

 <?php register_sidebars$number$args ); ?> 

Default Usage

register_sidebars() 用法

参数

number

(integer) (可选) Number of sidebars to create.

默认值: 1

args

(string/array) (可选) Builds Sidebar based off of 'name' and 'id' values.

默认值: None

  • name - Sidebar name.
  • id - Sidebar id. (Note: "%d" is added automatically to supplied 'id' value after the first; e.g., "Sidebar", "Sidebar-2", "Sidebar-3", etc.)
  • description - Text description of what/where the sidebar is. Shown on widget management screen. (Since 2.9) (default: empty)
  • class - CSS class name to assign to the widget HTML (default: empty).
  • before_widget - HTML to place before every widget.
  • after_widget - HTML to place after every widget.
  • before_title - HTML to place before every title.
  • after_title - HTML to place after every title.

The optional args parameter is an associative array that will be passed as a first argument to every active widget callback. (If a string is passed instead of an array, it will be passed through parse_str() to generate an associative array.) The basic use for these arguments is to pass theme-specific HTML tags to wrap the widget and its title.

register_sidebars() 参数

返回值

None.

register_sidebars() 返回值

源文件

register_sidebars() 函数的代码位于 wp-includes/widgets.php.

register_sidebars() 源文件

相关