How to Create a New Widget Area

,

So here is the code to initialize the widget for use in the admin area of your site.  More info as to what things should be set to can be found on the register_sidebar codex page.

function new_register_widget_init() {
	$args = array(
		'name'          => __( 'Sidebar name', 'theme_text_domain' ),
		'id'            => 'unique-sidebar-id',
		'description'   => '',
        	'class'         => '',
		'before_widget' => '<li id="%1$s" class="widget %2$s">',
		'after_widget'  => '</li>',
		'before_title'  => '<h2 class="widgettitle">',
		'after_title'   => '</h2>',
		 ); 
}
add_action('widgets_init', 'new_register_widget_init');

And then where you want the new widget to appear you can use the following code:

dynamic_sidebar( 'unique-sidebar-id' );

 

Skills

Posted on

September 23, 2016

Submit a Comment

Your email address will not be published. Required fields are marked *