How to create custom widget in WordPress ?

How to create custom widget in WordPress ?

Hi guy’s today i am gonna tell you how to create custom widget in WordPress. Widget is a very important part when you are building website in WordPress. Basically WordPress already have some widgets but when we are building the site we needs the more widgets to use in the site so follow these instructions to create widget in WordPress.

Before moving on let me tell you one thing that Please do not create new function for widget it has already present there you just have to add some code within the function and thats it. See the below instructions.

Step 1

Please put these code in your function.php file within this function.

function themename_widget_init()
your widget code goes here ..

Your widget code will be

register_sidebar( array(
    'name' => __( 'Widget Name', 'themename' ),
    'id' => 'widget_id',
    'description' => __( 'widget description.', 'themename' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

and your done now go to WordPress backend go to widget under appearance you can see the new widget name “Widget Name” you can change name whatever you wish to.

Please see this screenshot


Now you can display this widget anywhere by using this function

<?php dynamic_sidebar('widget-id'); ?>

Hope you like this tutorial if you have any question or comments please fill the form below. We would love to help you anytime.
Good Luck !

27 thoughts on “How to create custom widget in WordPress ?

  1. WordPress as of now have a few gadgets yet when we are build the site we have to needs the more gadgets to use in the site so take after these directions to make gadget in WordPress.

  2. Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards.

  3. Been sitting eyes wide open behind these four walls, hoping you’d call It’s just a cruel existence like there’s no point hoping at all. Baby, baby, I feel crazy, up all night, all night and every day Give me something, oh, but you say nothing. What is happening to me? I don’t wanna live forever, ’cause I know I’ll be living in vain. And I don’t wanna fit wherever. I just wanna keep calling your name until you come back home.Thank you

  4. I’ve been sleepless at night. ‘Cause I don’t know how I feel. I’ve been waiting on you
    Just to say something real.There’s a light on the road. And I think you know. Morning is coming. And I have to go.I don’t know why, I don’t know why. We need to break so hard. I don’t know why we break so hard But if we’re strong enough
    To let it in. We strong enough. To let it go.

  5. There is such a great amount in this article I would never have considered all alone. Your substance gives perusers things to consider in an intriguing way. Much obliged to you for your unmistakable data.

  6. Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.

  7. I was reading your article and wondered if you had considered creating an ebook on this subject. Your writing would sell it fast. You have a lot of writing talent.

  8. Thanks for the sharing this great article related to The Future of the Web.. this article is very usefull for me.Thanks again for sharing this great article!

  9. I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.

  10. I am happy you take pride in what you compose. This makes you stand way out from numerous different essayists that push inadequately composed substance. Love quotes

  11. The knowledge you share really changes me in life, I sincerely thank you for the things you have done, sure your blog will help more people. Sincerely thanks

  12. There is such a great amount in this article I would never have considered all alone. Your substance gives perusers things to consider in an intriguing way. Much obliged to you for your unmistakable data.

  13. I believe there are many other people who are interested in them just like me! How long does it take to complete this article? I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article! Thanks for your post!

Leave a Reply

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