- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/register sidebars
目次
Description
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.
Usage
%%% <?php register_sidebars( $number, $args ); ?> %%%
Default Usage
%%% <?php $args = array( 'name' => sprintf(__('Sidebar %d'), $i ), 'id' => 'sidebar-$i',
'before_widget' => '', 'after_title' => '
' ); ?> %%%Parameters
- $number
- (int) (必須) Number of sidebars to create.
- 初期値: なし
- $args
- (string/array) (optional) Builds Sidebar based off of 'name' and 'id' values.
- 初期値: なし
- name - Sidebar name.
- id - Sidebar id.
- before_widget - Text to place before every widget.
- after_widget - Text to place after every widget.
- before_title - Text to place before every title.
- after_title - Text 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.
Example
This will register 1 sidebar named Sidebar:
register_sidebars();
This will create 2 sidebars named “Foobar 1″ and “Foobar 2″:
register_sidebars(2, array('name'=>'Foobar %d'));
This will create 2 sidebars with <h1> and </h1> before and after the title:
register_sidebars(2, array('before_title'=>'<h1>','after_title'=>'</h1>'));
Change Log
Since: 2.2.0
Source File
register_sidebars() is located in wp-includes/widgets.php
.
最新英語版: WordPress Codex » Function Reference/register_sidebars (最新版との差分)
Related
ウィジェット API: is_active_widget(), the_widget(), register_widget(), unregister_widget() / en, wp_register_widget_control() / en, wp_unregister_widget_control() / en, wp_convert_widget_settings() / en, wp_get_widget_defaults() / en, wp_widget_description() / en