Create Custom Widgets Area In WordPress


Sometimes we are in a need to create our own widgets area in wordpress because the theme we use don’t support that. so in this quick wordpress tutorial we will guide you step by step to achieve that. Just note please that creating custom widget area is something like creating your own sidebar widget area, but with the flexibility to place it anywhere in between your template code, so that might be in page.php, index.php, header.php or footer.php.

– Open your functions.php and add the bellow code in it :

if ( function_exists('register_sidebar') )
    register_sidebar( array(
   'name' => __( 'My Custom Widget Area - 1'),
   'id' => 'mycustomwidgetarea',
   'description' => __( 'An optional widget area for your site footer', 'twentyeleven' ),
   'before_widget' => '<aside id="%1$s" class="widget %2$s">',
   'after_widget' => "</aside>",
   'before_title' => '<h3 class="widget-title">',
   'after_title' => '</h3>',
   ) );

– Now we will call the widgets area from theme template files. For that you just have to place this code in the div or any other container you wish. You can place the bellow code in – header.php, footer.php, page.php, index.php, single.php or any other template related files :

 // Custom widget Area Start
 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('My Custom Widget Area - 1') ) : ?>
<?php endif;
// Custom widget Area End

Now you are done! your widget area is ready to drag your widgets in it.



Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.