Adding widget areas in wordpress header

To add a header widget areas,first in your theme’s function.php add the following code to register a sidebar.

if (function_exists(‘register_sidebars’)) {
register_sidebar(array(‘name’ => ‘Header1′));
register_sidebar(array(‘name’ => ‘Header2′));
}

This is assuming that you want to add 2 header widgets

Next you will need to insert the following code in your theme’s header.php above or below the navigation menu as you prefer where the widgets should appear.

<div>
<table style="list-style:none;border:none;" align="center">
<td><?php if ( !function_exists(‘dynamic_sidebar’)|| !dynamic_sidebar(‘Header1′) ) : ?><?php endif; ?>
</td>
</table>
</div>
<div>
<table style="list-style:none;border:none;" align="center">
<td><?php if ( !function_exists(‘dynamic_sidebar’)|| !dynamic_sidebar(‘Header2′) ) : ?><?php endif; ?>
</td>
</table>
</div>

Now open widgets from admin and start using them !



That is all.

If you liked this article please do leave a reply and share it with friends.

Thanks.

Leave a Reply

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

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