How to add new sidebar widget area to child theme?

I want to create a new sidebar widget area in the header of my child theme. What would be the best way to do this?

Here is the code for one of the sidebars in the parent theme:

<?php
add_action( 'widgets_init', 'ci_widgets_init' );
if ( ! function_exists( 'ci_widgets_init' ) ) :
    function ci_widgets_init() {
        register_sidebar( array(
            'name'          => __( 'Blog Sidebar', 'ci_theme'),
            'id'            => 'blog-sidebar',
            'description'   => __( 'The list of widgets assigned here will appear in your blog posts.', 'ci_theme'),
            'before_widget' => '<aside id="%1$s" class="widget %2$s group">',
            'after_widget'  => '</aside>',
            'before_title'  => '<h3 class="widget-title"><span>',
            'after_title'   => '</span></h3>',
        ) );
    }

Can I just change the name, id and description, and put it in my child theme’s functions.php file?

Solutions Collecting From Web of "How to add new sidebar widget area to child theme?"

Well, this is what worked for me. In my functions.php file I put the following code:

function header_widgets_init() {

register_sidebar( array(

    'name' => 'Header Sidebar',

    'id' => 'header_sidebar',

    'before_widget' => '<aside class="widget %2$s">',

    'after_widget' => '</aside>',

    'before_title' => '<h2 class="widget-title">',

    'after_title' => '</h2>',

) );

}

add_action( 'widgets_init', 'header_widgets_init' );

…and in my header.php file I used:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('header_sidebar') ) : endif; ?>

Short answer is yes, adding the widget directly in the child theme functions.php file is perfectly acceptable.

Some parent themes provide recommendations on how best to add new functionality within child themes (helpers, classes, specific design patterns, etc.) so the ideal approach may vary from one theme to the next.

I’m happy to elaborate if you can provide any additional information about your setup.