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.
Do You Like This Article? Get It In Your Inbox Daily.
Among the many digital tools that are being used with increasing frequency, the one that has the greatest...
Having a Best Website like opening a door and inviting…
In this internet era, the business website is the most…
The Live chat is the common thing now days, if…
- Artificial Intelligence
- Augmented Reality
- Business Development
- Cloud Server
- Digital Marketing
- Featured Post
- Guru Technolabs
- Mobile App Development
- Real Estate
- Social Media
- Web Development
- Web Scraping
- Website Design
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.