custom widget area in wordpress

custom widget area in wordpress

WordPress
Amitpal Singh
First of all place this code in function.php file to register a widget. Make sure that this widget name is unique and different for each.

[php]
if (function_exists(‘register_sidebar’)) {
register_sidebar(array(
‘name’ => ‘Extra Widgets’,
‘id’ => ‘extra-widgets’,
‘description’ => ‘The extra widgets for your website.’,
‘before_widget’ => ‘<div id="%1$s" class="widget %2$s">’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’
));
}
[/php]

after this, You can place this below code where you want to show the widget content:

[php]
<?php
if (!function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Extra Widgets’)) :
endif; ?>
[/php]

Screenshot: