Codex tools: Log in
Languages: English • Español • 日本語 • Português do Brasil • (Add your language)
Contents |
Builds the definition for a single sidebar and returns the ID. Call on "widgets_init" action.
<?php register_sidebar( $args ); ?>
<?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>' ); ?>
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.
This will create a sidebars named "RightSideBar" with <h1> and </h1> before and after the title:
register_sidebar(array( 'name' => 'RightSideBar', 'id' => 'right-sidebar', 'description' => 'Widgets in this area will be shown on the right-hand side.', 'before_title' => '<h1>', 'after_title' => '</h1>' ));
register_sidebar() 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()