How to Add a Widget Area in WordPress Theme

In this WordPress tutorial I will explain how to add a widget area in your WordPress theme.
I am going to add a new widget area named Footer.

Step 1

Open functions.php of your theme and add following codes at the bottom.

function themename_widgets_init() {
register_sidebar( array(
'name'          => esc_html__( 'Footer', 'themename' ),
'id'            => 'footer',
'description'   => 'Footer Widget Description',
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget'  => '</section>',
'before_title'  => '<h2 class="widget-title">',
'after_title'   => '</h2>',
) );
add_action( 'widgets_init', 'themename_widgets_init' );

Step 2

Now add following codes where you want widget to appear. I am adding in footer.php file of theme. Open footer.php and add follwing codes.

<?php dynamic_sidebar( 'footer' ); ?>

Hope this article helped you.