function mytheme_widgets_init() {
register_sidebar( array(
'name' => __( 'Single Post Widgets', 'textdomain' ),
'id' => 'mytheme-single-post-widgets',
'description' => __( 'Widgets in this area will be shown under your single posts, before comments.', 'textdomain' ),
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
add_action( 'widgets_init', 'mytheme_widgets_init' );
For example, used with registering sidebars:
You should note that the
widgets_init
hook is fired as part of theinit
hook – with a priority of 1.This means that it will fire before any code you may add to the
init
hook with a default priority.