Advertisements

register_sidebar

Definition:
function register_sidebar($args = array() {}

Builds the definition for a single sidebar and returns the ID.
The $args parameter takes either a string or an array with ‘name’ and ‘id’ contained in either usage. It will be noted that the values will be applied to all sidebars, so if creating more than one, it will be advised to allow for WordPress to create the defaults for you.

Parameters

  • string|array $args: Builds Sidebar based off of ‘name’ and ‘id’ values

Return values

returns:The sidebar id that was added.

Defined actions

  • register_sidebar
    do_action( 'register_sidebar', $sidebar );

Source code

function register_sidebar($args = array()) {

	global $wp_registered_sidebars;



	$i = count($wp_registered_sidebars) + 1;



	$defaults = array(

		'name' => sprintf(__('Sidebar %d'), $i ),

		'id' => "sidebar-$i",

		'description' => '',

		'class' => '',

		'before_widget' => '<li id="%1$s" class="widget %2$s">',

		'after_widget' => "</li>\n",

		'before_title' => '<h2 class="widgettitle">',

		'after_title' => "</h2>\n",

	);



	$sidebar = wp_parse_args( $args, $defaults );



	$wp_registered_sidebars[$sidebar['id']] = $sidebar;



	add_theme_support('widgets');



	do_action( 'register_sidebar', $sidebar );



	return $sidebar['id'];

}

2679

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: