Create a Widgetized Area In A WordPress Theme

Ever wondered how you can make a certain area of your theme files in WordPress show a widget? Follow our quick tutorial on how to make a widgetized area.

For this Tutorial i’m going to add a Widget area named footer. You can rename this anything you like, just make sure the two name’s and id’s match without spaces.

Firstly, in your theme files, put this in the area you want the widgets to sit, the html present is what you want to show if there isn’t any widgets present.:

<?php if (function_exists(‘dynamic_sidebar’) && dynam7c20b</span>4″ class=”textannotation”>rn:enhancement-78112b20-c29a-b16d-572d-5</span>19216e1f463=”” class=”textannotatent-a8ff4e45-45ec-b969-2a9e-c021cd68bc97″ class=”textannotation”>>-ff20-4ba2c633a2a2″ class=”textannotation”>n:enhancement-8e63e0bd-3c62-5d00-3ee4-b408301713b5=””>ion”>ion”>d6″ class=”textannotation”>ic_sidebar(‘Footer’)) : else : ?>
<div class=”footer”>
<p><strong>Widgetized Footer</strong>&lt;/p>
<p>This panel is active and ready for you to add some widgets via the WP Admin</p>
</div>
<?php endif; ?>

Then in your functions.php add:

register_sidebar(array(
‘name’ => ‘Footer’,
‘id’ => ‘Footer’,
‘description’ => ‘Footer Widget.’,
‘before_widget’ => ‘<div class=”footer”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h3>’,
‘after_title’ => ‘</h3>’
));

As you can see, you have a choice of how you want to display it, what goes before and after it and what the title tag is wrapped in.

Once you have done this, all you need to do is go to the WordPress admin and add widgets to your newly defined Widget area!

Tagged

, ,