register_sidebars

Sponsored Link

複数のサイドバーを作成します。

Sponsored Link

Creates multiple sidebars.

現在のテーマで使用する1つまたは複数のサイドバーを登録します。ほとんどのテーマは1つだけサイドバーがあります。この理由は、数値パラメーターがオプションで、デフォルトが1つだからです。

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.

args配列パラメーターは、1つ以上のサイドバーがある場合は、サイドバーの番号の前に付加される’name’を含めることができます。名前が指定されない場合は、’Sidebar’が使用されます。

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 ); ?>

デフォルトの使用方法

<?php $args = array(
	'name'          => sprintf(__('Sidebar %d'), $i ),
	'id'            => "sidebar-$i",
	'before_widget' => '<li id="%1$s" class="widget %2$s">',
	'after_widget'  => '</li>',
	'before_title'  => '<h2 class="widgettitle">',
	'after_title'   => '</h2>' ); ?>

register_sidebarsのパラメーター

number

(integer) (optional) 作成するためのサイドバーの数。
Default: 1

(integer) (optional) Number of sidebars to create.
Default: 1

args

(string/array) (optional) ‘name’と ‘id’の値に基づいてサイドバーを作成します。
Default: なし

(string/array) (optional) Builds Sidebar based off of ‘name’ and ‘id’ values.
Default: None

  • name – サイド名。 (注: 上記のデフォルトの使用方法からコピーする場合は、sprintf()のラッパー関数を削除します。)
  • id – サイドバーID (注: “-$i”が”最初の’id’値の後に提供するために自動的に追加します。; 例, “Sidebar”, “Sidebar-2”, “Sidebar-3”, など.)
  • before_widget – HTMLは、すべてのウィジェットの前に配置します。
  • after_widget – HTMLは、すべてのウィジェットの後に配置します。
  • before_title – HTMLは、すべてのタイトルの前に配置します。
  • after_title – HTMLは、すべてのタイトルの後に配置します。
  • name – Sidebar name. (Note: If copying from default usage above, remove sprintf( ) wrapper function.)
  • id – Sidebar id. (Note: “-$i” is added automatically to supplied ‘id’ value after the first; e.g., “Sidebar”, “Sidebar-2”, “Sidebar-3”, etc.)
  • 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.

オプションのargsパラメーターは、全てのアクティブなウィジェットのコールバックへの最初の引数として渡される連想配列です。(文字列が配列の代わりに渡された場合。それは連想配列を生成するためにparse_str()を通過されます)これらの引数の基本的な使用方法は、ウィジェットとそのタイトルを囲むためにテーマ固有のHTMLタグを渡すことです。

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.

戻り値

なし

これはサイドバーという名前のサイドバーを1つ登録します

This will register 1 sidebar named Sidebar:

register_sidebars();

これは“Foobar 1″ と “Foobar 2″という名前のサイドバーを2つ作成します:

This will create 2 sidebars named “Foobar 1″ and “Foobar 2″:

register_sidebars(2, array('name'=>'Foobar %d'));

これはタイトルの前後に

つけるサイトバーを2つ作成します。

This will create 2 sidebars with

and

before and after the title:

register_sidebars(2, array('before_title'=>'<h1>','after_title'=>'</h1>'));

変更ログ

Since: 2.2.0

ソースファイル

register_sidebars()は、wp-includes/widgets.php内に位置しています。

register_sidebars() is located in wp-includes/widgets.php.

関連ファンクションタグ

Sidebars: is_active_sidebar(), register_sidebars(), register_sidebar(), unregister_sidebar(), is_dynamic_sidebar(), dynamic_sidebar(), wp_register_sidebar_widget(), wp_unregister_sidebar_widget(), wp_get_sidebars_widgets(), wp_set_sidebars_widgets()

Widgets: is_active_widget(), the_widget(), register_widget(), unregister_widget(), wp_register_widget_control(), wp_unregister_widget_control(), wp_convert_widget_settings(), wp_get_widget_defaults(), wp_widget_description()

Sponsored Link