• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「関数リファレンス/register sidebar」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Function Reference/register_sidebar 23:23, 30 December 2009 Ramiy 版を翻訳用にコピー)
 
(整形・リンク調整。未翻訳)
1行目: 1行目:
 +
{{NeedTrans}}
 
== Description ==
 
== Description ==
  
5行目: 6行目:
 
== Usage ==
 
== Usage ==
  
%%% <?php register_sidebar( $args ); ?> %%%
+
<?php register_sidebar( $args ); ?>
  
 
===Default Usage===
 
===Default Usage===
  
%%% <?php $args = array(
+
<pre>
 +
<?php $args = array(
 
'name'          => sprintf(__('Sidebar %d'), $i ),
 
'name'          => sprintf(__('Sidebar %d'), $i ),
 
'id'            => 'sidebar-$i',
 
'id'            => 'sidebar-$i',
16行目: 18行目:
 
'after_widget'  => '</li>',
 
'after_widget'  => '</li>',
 
'before_title'  => '<h2 class="widgettitle">',
 
'before_title'  => '<h2 class="widgettitle">',
'after_title'  => '</h2>' ); ?> %%%
+
'after_title'  => '</h2>' ); ?>
 +
</pre>
  
 
(No backslashes before the double quotes, the Codex's PHP highlighter seems to be screwy.)
 
(No backslashes before the double quotes, the Codex's PHP highlighter seems to be screwy.)
35行目: 38行目:
 
== Notes ==
 
== Notes ==
  
* The only times you might need to call this function instead of [[Function Reference/register sidebars|register_sidebars()]] are when you want to give unique names to sidebars, such as “Right Sidebar” and “Left Sidebar”, or when they should be marked up differently. The names only appear in the admin interface but they are also used as an index for saving the sidebar arrangements. Consequently, sidebars can have their arrangements reused and overwritten when another theme is chosen that uses the same names.
+
* The only times you might need to call this function instead of [[関数リファレンス/register_sidebars|register_sidebars()]] are when you want to give unique names to sidebars, such as “Right Sidebar” and “Left Sidebar”, or when they should be marked up differently. The names only appear in the admin interface but they are also used as an index for saving the sidebar arrangements. Consequently, sidebars can have their arrangements reused and overwritten when another theme is chosen that uses the same names.
  
 
* The default before/after values are intended for themes that generate a sidebar marked up as a list with h2 titles. This is the convention we recommend for all themes and any theme built in this way can simply register sidebars without worrying about the before/after tags. If, for some compelling reason, a theme cannot be marked up in this way, these tags must be specified when registering sidebars. It is recommended to copy the id and class attributes verbatim so that an internal sprintf call can work and CSS styles can be applied to individual widgets.
 
* The default before/after values are intended for themes that generate a sidebar marked up as a list with h2 titles. This is the convention we recommend for all themes and any theme built in this way can simply register sidebars without worrying about the before/after tags. If, for some compelling reason, a theme cannot be marked up in this way, these tags must be specified when registering sidebars. It is recommended to copy the id and class attributes verbatim so that an internal sprintf call can work and CSS styles can be applied to individual widgets.
51行目: 54行目:
 
</pre>
 
</pre>
  
== Change Log ==
+
== Changelog ==
  
 
* Since: [[Version 2.2|2.2.0]]
 
* Since: [[Version 2.2|2.2.0]]
68行目: 71行目:
 
{{Tag Footer}}
 
{{Tag Footer}}
  
[[Category:Functions]]
+
{{DEFAULTSORT:Register_sidebar}}
[[Category:Widgets]]
+
[[Category:ウィジェット]]
 +
[[Category:wp2.2]]
 +
[[Category:wp2.9]]
  
 
[[en:Function Reference/register_sidebar]]
 
[[en:Function Reference/register_sidebar]]

2010年3月3日 (水) 22:17時点における版

このページ「関数リファレンス/register sidebar」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

Description

Builds the definition for a single sidebar and returns the ID.

Usage

<?php register_sidebar( $args ); ?>

Default Usage

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

(No backslashes before the double quotes, the Codex's PHP highlighter seems to be screwy.)

Parameters

$args
string/array) (optional) Builds Sidebar based off of 'name' and 'id' values.
初期値: なし
  • name - Sidebar name.
  • id - Sidebar id.
  • description - Sidebar description. (Since 2.9)
  • 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.

Notes

  • The only times you might need to call this function instead of register_sidebars() are when you want to give unique names to sidebars, such as “Right Sidebar” and “Left Sidebar”, or when they should be marked up differently. The names only appear in the admin interface but they are also used as an index for saving the sidebar arrangements. Consequently, sidebars can have their arrangements reused and overwritten when another theme is chosen that uses the same names.
  • The default before/after values are intended for themes that generate a sidebar marked up as a list with h2 titles. This is the convention we recommend for all themes and any theme built in this way can simply register sidebars without worrying about the before/after tags. If, for some compelling reason, a theme cannot be marked up in this way, these tags must be specified when registering sidebars. It is recommended to copy the id and class attributes verbatim so that an internal sprintf call can work and CSS styles can be applied to individual widgets.

Example

This will create a sidebars named "RightSideBar" with <h1> and </h1> before and after the title:

register_sidebar(array(
'name' => 'RightSideBar',
'description' => 'Widgets in this area will be shown on the right-hand side.',
'before_title' => '<h1>',
'after_title' => '</h1>'));

Changelog

Source File

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

最新英語版: WordPress Codex » Function Reference/register_sidebar最新版との差分

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



関数リファレンステンプレートタグ目次もご覧ください。