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

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

関数リファレンス/register sidebar

提供: WordPress Codex 日本語版
< 関数リファレンス
2010年3月3日 (水) 22:12時点におけるBono (トーク | 投稿記録)による版 (en:Function Reference/register_sidebar 23:23, 30 December 2009 Ramiy 版を翻訳用にコピー)

(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

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' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ' ); ?> %%%

    (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>'));
    

    Change Log

    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



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