Today’s WordPress themes are becoming more and more flexible where web design is concerned, but I’m still asked from time to time to create custom widget areas for clients.   Fortunately, the process is a fairly simple one and you can create a simple widget area via your functions.php file.

Simply add the following code to your functions.php file of your theme.

Register your new Widget Area

/** Register Widget Area. **/
function mycustom_widgets_init() {
 register_sidebar( array(
 'name' => 'My Custom Sidebar',
 'id' => 'my_custom_sidebar',
 'before_widget' => '<div>',
 'after_widget' => '</div>',
 'before_title' => '<h2 class="rounded">',
 'after_title' => '</h2>',
 ) );
add_action( 'widgets_init', 'mycustom_widgets_init' );
Your new widget area will now be available in the Appearance > Widgets area of your WordPress Dashboard.

Display your new Widget Area in your theme

Once your widget area has been registered, there’s still the matter of displaying it within your theme. Again, this is a fairly simple process. Add the following code to your functions.php file after the code above.

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