• Jun
  • 07
  • 2012

Manier times when you are developing site at that time you come across requirement for adding new(extra) widget in the wordpress admin panel. So I did some RnD and found a very quick and easy way to add new(extra) widget in wordpress admin panel.

This kind of requiremnt arise when the design has many small modules and each page contain different modules and client want those module to be user friendly. So now it won’t be headache for you and your client. 🙂

Go to your theme folder and find functions.php in your theme folder.

Now find thie piece of code in functions.php. This will be around 429 line no of twentyten theme. 🙂

Code for Adding Additional widget in WordPress :

// Area 6, located in the footer. Empty by default.
register_sidebar( array(
'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
'id' => 'fourth-footer-widget-area',
'description' => __( 'The fourth footer widget area', 'twentyten' ),
'before_widget' => '
<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>
',
'before_title' => '
<h3 class="widget-title">',
'after_title' => '</h3>
',
) );

Now add this code just below above code.

register_sidebar( array(
'name' => __( 'Test Widget Area', 'twentyten' ),
'id' => 'test-widget-area',
'description' => __( 'The test widget area', 'twentyten' ),
'before_widget' => '
<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>
',
'before_title' => '
<h3 class="widget-title">',
'after_title' => '</h3>
',
) );

You are done !! 🙂

You can see that we just have copied the default widget code and replaced some of the ids and name of the widget in the code. You can add as many widgets as you want by repeating the above code and replacing the name and ids.

After adding this in your function.php, in admin, you can see one sidebar block in widget.

Now How to show this particular sidebar in template ? Its also an easy task. Open template file (you can also put this in page.php).

And place below code in at location where you want to show that widget:

<?php if ( is_active_sidebar( 'test-widget-area' ) ) : ?>
<div id="first">

<?php dynamic_sidebar( 'test-widget-area' ); ?>

</div>
<?php endif; ?>

Thats it !! You can add as many widgets as you want in your site. You can make unique look.

If you have any doubt or any query then comment on this or you can directly contact me via contact form.

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Popular Blogs

recent-blog-image

Among the many digital tools that are being used with…

recent-blog-image

This question is most searched question in google. It is…

recent-blog-image

When you are using WPML in wordpress at that time…

recent-blog-image

Method for linking pages that aren't in a Site Menu…

recent-blog-image

Manier times we come across requirement like fetching/getting content from…

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.