Codex tools: Log in / create account
Contents |
Builds the definition for a single sidebar and returns the ID.
<?php register_sidebar( $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>' ); ?>
(No backslashes before the double quotes, the Codex's PHP highlighter seems to be screwy.)
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', 'before_title'=>'<h1>','after_title'=>'</h1>') );
Since: 2.2.0
register_sidebar() is located in wp-includes/widgets.php.
Widgets API: is_active_sidebar, register_sidebars, register_sidebar, unregister_sidebar, is_dynamic_sidebar, dynamic_sidebar, register_sidebar_widget, unregister_sidebar_widget, wp_register_sidebar_widget, wp_unregister_sidebar_widget, wp_get_sidebars_widgets, wp_set_sidebars_widgets, is_active_widget, the_widget, register_widget, unregister_widget, register_widget_control, unregister_widget_control, wp_register_widget_control, wp_unregister_widget_control, wp_convert_widget_settings, wp_get_widget_defaults, wp_widget_description