Add sidebar widget support to your WordPress theme

First, let’s go to your theme’s sidebar.php. Add the following where you want your sidebar widgets to be listed:

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

Then, add this to your functions.php:

/*  Register sidebars
/* ------------------------------------ */
function alx_sidebars()	{
	register_sidebar(array( 'name' => 'Primary','id' => 'primary','description' => "Normal full width sidebar", 'before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));
add_action( 'widgets_init', 'alx_sidebars' );

That’s all you need to make your theme widget-ready. Give it a go!

Function reference: register_sidebar