Add widget areas to WordPress theme

I can’t imagine a WordPress website without widgets areas. Those are the areas where you put important navigation features as tag cloud, list of categories, recent posts, links, custom content blocks and many more. In order to make a theme more flexible and easy to customize it’s a must to have few widget areas available. But how to enable multiple widget areas on your theme?
We need to define our widget areas in functions.php of our theme and later “call” them in sidebar, header, footer or wherever you want them to appear. Here is how we define a widget area:

if (function_exists('register_sidebar')) {
		'name'=> 'Right sidebar',
		'id' => 'right_sidebar',
		'before_widget' => '<li id="%1$s" class="widget %2$s">',
		'after_widget' => '</li></section>',
		'before_title' => '<section><h3>',
		'after_title' => '</h3>',

You can add more register_sidebar arrays. What’s important is to keep the name and id fields different. Let’s say we have one which is header_sidebar, then there could be another one header_widgets, and footer_widgets. The code in after_title, before_title, after_widget is used to hook the css styles.

Great, the widget area is defined, now we have to call it in a template file, like our sidebar.

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

That’s all that is required and it’s not rocket science as you can see.

WordPress Widgets – Codex

How to Create new Widget Area – WordPress Support forums

Leave a Reply

Your email address will not be published. Required fields are marked *