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…
This question is most searched question in google. It is…
When you are using WPML in wordpress at that time…
Method for linking pages that aren't in a Site Menu…
Manier times we come across requirement like fetching/getting content from…
- Artificial Intelligence
- Augmented Reality
- Digital Marketing
- Ecommerce Solutions
- Ecommerce Web Design
- Email Template Design
- mobile app design
- Mobile App Development
- Static Website Design
- UI/UX Design
- Virtual Reality
- Web Development
- Web Scraping
- Website Design
- Website Redesign
- WordPress Customization
- WordPress Plugin
- Zen Cart
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.