Creating Widget Space in WordPress

About Widgets:

WordPress widgets are plug-able items that enhance the features of a site. One can think of wordpress widget as a cassette that needs to be inserted into an available slot so that it performs it’s functions accordingly. Here slot refers to the the widgetized areas that are available according to the nature of the wordpress theme being used.

Different themes have different widget areas , for instance a theme might support a widget in the header section, or a sidebar of the theme or maybe in the footer area of the theme. Most commonly, themes contain widget slots for the sidebars but wordpress provides with flexibility to custom integrate a widget slot anywhere in the theme, having said that, a bit of advanced knowledge is required to accomplish the required outcome.

Custom widget area is used to create a slot for widgets to be placed over them in the admin widgets area. There are a number of widgets that can be placed over these slots such as sidebar widgets for post categories, tag clouds, navigation, search, etc To appear, like in sidebar, in footer, in header, hence where ever their particular slots are defined. Custom widget area provides an easy-to-use drag and drop feature to wordpress users, where user can simply drag widgets from the available widgets to the widget area where they want the widget to be displayed.
You can find “Widgets” under the tab “Appearance” in Admin panel: Appearance -> Widgets
 

How to enable widget area in wordpress theme

Custom widget area is enabled from function.php that is available in the themes folder.
Add the following code in function.php to enable/register widget area in the wordpress theme:
if (function_exists('register_sidebar')) {
     register_sidebar(array(
      'name' => 'Haneef Widgets',
      'id'   => 'sidebar-widgets',
      'description'   => 'Widget Area',
      'before_widget' => '<div id="one">',
      'after_widget'  => '</div>',
      'before_title'  => '<h2>',
      'after_title'   => '</h2>'
     ));
    }

 

How to add widget area in wordpress theme

Once you have enabled the function in function.php you can make any area as a widget area within a wordpress theme. Add the following code to the area ( sidebar, footer, header ) where you want the widget to to make a slot and add widget to it later from widgets setting panel:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Haneef Widgets') ) : ?>
      <?php endif; ?>


NOTE: If you want more then one area to be widgetized at the same time, then you have to register sidebar in function.php more then once with different names and id’s 

Now that you have enabled the widget area as well as created a slot for the widgets to be placed in, you can go to Appearance -> Widgets in admin panel and add the widgets to the slot you have just created..