How to create custom wordpress widget

In this post, I am going to explain “How to create custom WordPress Widget”. WordPress has some default widgets that you can use easily by just dragging it to the widget area. But if you want something special OR in your way you need to write your own custom code. Most of people create widgets using theme functions.php file but there are some drawbacks like whenever your theme update then your code get lost and also your widget code stop workign automatically. So I will always suggest don’t make changes directly in theme file. If you require any functionality then create your seprate plugin for that functionality this is the best way of creating any functionality in wordpress without any risk.

Before we get started, it would be best if you create a specific plugin where you will be pasting the widget code from this post.

You can also paste the code in your theme’s functions.php file. However, it will only be available when that particular theme is active.



In this post, we will create a simple widget that just greets visitors. Take a look at this code and then paste it in your specific plugin to see it in action.

After adding the code you need to go to the widget page. You will notice the new Webprepration Widget in the list of available widgets. You need to drag and drop this widget to a sidebar.

There are most important few things that you might want to know like web_prep_widget_domain ? If your are creating custom widget for your theme then you can change web_pre_widget_domain to your theme’s text domain.

We hope this post helped you learn how to easily create a custom WordPress widget.

Thanks!!!

 

143 thoughts on “How to create custom wordpress widget”

  1. Working as a freelancе рaralеgal has components in its favor,
    and elements that are adverse to some people. If a sense of adveenture and pleasure in your work life iss what
    wouһld sѡimsuit you tһe most еffective, freelancing could be ann awesome possibility for you!

    Reply
  2. Hello there, I found your web site via Google even as searching for a comparable topic, your web site
    came up, it seems great. I have bookmarked it in my google bookmarks.

    Hi there, simply was alert to your weblog through Google, and
    found that it’s truly informative. I’m going to
    be careful for brussels. I’ll be grateful in the event you continue this in future.
    Lots of other people shall be benefited from your writing.

    Cheers!

    Reply
  3. Wow, superb weblog structure! Just how long
    have you been blogging for? you make blogging effortless.

    The entire look of your web site is superb, neatly as the content
    material!

    Reply
  4. Hello there I’m so pleased I find your website, I truly found you
    by mistake, while I was looking on yahoo and google
    for something else, Anyhow I’m here now and could just like to say many thanks for a tremendous post as well as interesting website.

    Please do continue the truly amazing work.

    Reply
  5. Wow! This might be one of the most helpful blogs we’ve ever arrive across on this subject.Excellent.
    I’m also an expert in this topic thus I can understand your effort.

    Reply
  6. This design is spectacular! You definitely know how to keep a reader entertained.
    Between your wit and your videos, I was almost moved
    to start my own blog (well, almost…HaHa!) Excellent job.
    I really loved what you had to say, and more than that, how
    you presented it. Too cool!

    Reply
  7. Hey just wanted to give you a brief heads up and let you know
    a few of the images aren’t loading correctly. I’m not sure why but I think
    its a linking issue. I’ve tried it in two different internet
    browsers and both show the same results.

    Reply
  8. Hmm is anyone else encountering problems with the pictures on this blog
    loading? I’m trying to find out if its a problem
    on my end or if it’s the blog. Any suggestions would be greatly appreciated.

    Reply
  9. Greate article. Keep posting such kind of info on your blog.
    Im really impressed by your site.
    Hi there, You’ve done a fantastic job. I will definitely digg it and in my view suggest to my friends.
    I’m sure they will be benefited from this site.

    Reply
  10. Fine way of describing, and good paragraph to take information concerning my presentation subject, which i
    am going to present in school.

    Reply
  11. I was recommended this blog by my cousin. I am
    no longer positive whether or not this submit is written by
    way of him as nobody else understand such unique approximately
    my problem. You are wonderful! Thanks!

    Reply
  12. Hello there, just became aware of your blog through Google, and found that it is truly informative. Im gonna watch out for brussels. Ill be grateful if you continue this in future. Lots of people will be benefited from your writing. Cheers!

    Reply
  13. You actually make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complex and very broad for me. I’m looking forward for your next post, I will try to get the hang of it!

    Reply
  14. If some one desires expert view about blogging and site-building after that i suggest him/her to visit this weblog, Keep up the good work.

    Reply
  15. An interesting discussion is definitely worth comment. I think that you should write
    more on this subject matter, it may not be a taboo matter but usually people don’t speak
    about such subjects. To the next! Best wishes!!

    Reply
  16. Thanks for sharing exceptional informations.
    Your site is very cool. I’m astounded by the details which you’ve
    put on this web site. It reveals how nicely you recognize
    this subject. Bookmarked this web page, will return for a lot more articles.
    You, my friend, ROCK! I discovered simply the information I already searched in all places and simply
    couldn’t come across. What an ideal website.

    Reply
  17. Hello, the whole thing is going nicely here and ofcourse every one is sharing
    facts, that’s truly good, keep up writing.

    Reply
  18. Thhis iѕ very inteгesting, Уou’re an excessively professional blogger.

    І have joined ykur feed and sit up for
    lookihg fоr extra оf үour fantastic post. Also, I have shared үoսr website
    іn my social networks

    Reply
  19. I like this post, enjoyed this one thank you for putting up. No man is wise enough by himself. by Titus Maccius Plautus. bddedcegecdk

    Reply
  20. What’s up it’s me, I am also visiting this site daily, this website is actually pleasant and the visitors are really sharing fastidious thoughts. eecfaddkebea

    Reply
  21. Hi my friend! I want to say that this post is amazing, great written and include almost all significant infos. I’d like to see more posts like this. agecdebbdgeg

    Reply
  22. Howdy! I basically would like to give a huge thumbs up for the good data you’ve got here on this post. I will probably be coming once again to your weblog for far more soon. kacbkfbfdedakbae

    Reply
  23. Thanks for another magnificent post. Where else may just anybody get that kind of info in such a perfect manner of writing? I have a presentation next week, and I’m at the look for such information. gfdebffffekc

    Reply
  24. Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thanks kcddeckcddgkefbc

    Reply
  25. Helpful info. Fortunate me I found your website by chance, and I’m shocked why this twist of fate did not took place earlier! I bookmarked it. baggddgegeba

    Reply
  26. Pretty nice post. I just stumbled upon your blog and wanted to say that
    I have truly enjoyed surfing around your blog posts.
    In any case I will be subscribing to your feed and I hope you write again very soon!

    Reply
  27. I just could not leave your website before suggesting that I actually
    loved the usual info a person provide to your visitors?

    Is going to be back continuously to inspect new posts

    Reply
  28. Howdy very cool web site!! Guy .. Excellent .. Superb ..
    I’ll bookmark your website and take the feeds also?
    I’m satisfied to seek out a lot of helpful info right here in the put up,
    we’d like develop more strategies on this regard, thank you for sharing.
    . . . . .

    Reply
  29. How to create custom wordpress widget is certainly
    impressive! I wish I really know tends to make
    recently. Furthermore buddys most of us converse the idea just about any time.
    So it’s accordingly fantastic which you just team discuss it so!
    Owing!

    Reply
  30. Many thanks! It was very interesting to read, just as usual.
    Keep writing! I’m enthusiastic about read some brand new articles from you.
    Having great writing talents is good but not everybody is able to be a very good
    writer. So what exactly to do in the case if you need to
    write a lot but you are awful at it? I don’t know whether I really could take care of this difficulty without this web page online essay writing service review.
    The staff of the web page produces superb critiques of many essays authoring firms in order
    to assist people stay away from fraud and locate top firms.

    Reply
  31. I’ve never taken into account %BT% in this way. Thank you very
    much author, it was very interesting to read!
    I’m a little bit jealous because I can’t write as great as
    you. Penning activities makes me cry and nervous since I must compose a lot thanks to our modern academic system.
    To evade this problem you can buy a essay from one of the writing organizations that
    exist in the internet. But much of them are undependable.
    That’s why I always read these guys custom writing services reviews.
    Their critiques of writing companies assisted me a lot!

    Reply
  32. Oh my goodness! Impressive article dude! Thanks, However I am having troubles with your RSS.
    I don’t understand why I can’t subscribe to it.

    Is there anybody else having identical RSS problems? Anyone who
    knows the answer can you kindly respond? Thanks!!

    Reply
  33. I just want to tell you that I am just very new to blogging and site-building and definitely liked your blog. Likely I’m likely to bookmark your blog . You definitely come with great article content. Thanks a bunch for revealing your blog.

    Reply
  34. Thanks for sharing your extraordinary and amazing ideas.
    I will not be reluctant to share your website to any individual who should
    be given ideas such as these.

    Reply
  35. I believe other website owners should take this internet site as an model, very clean and excellent user pleasant style and design.

    Reply
  36. Greetings! I’ve been following your site for some time
    now and finally got the courage to go ahead and give you a
    shout out from Huffman Texas! Just wanted to say keep up the good work!

    Reply
  37. Hello there I am so delighted I found your weblog, I
    really found you by mistake, while I was looking on Yahoo for something else, Nonetheless I am here now and would just like to
    say cheers for a marvelous post and a all round thrilling blog (I also
    love the theme/design), I don’t have time to look over it all at
    the minute but I have bookmarked it and also included your RSS feeds, so when I have time I will be back to read much more, Please do keep up the awesome work.

    Reply
  38. I have been browsing online more than three hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my view, if all site owners and bloggers
    made good content as you did, the internet will be much more useful than ever before.

    Reply
  39. There are definitely a lot of particulars like that to take into consideration. That is a nice level to bring up. I provide the thoughts above as common inspiration but clearly there are questions like the one you convey up the place a very powerful thing might be working in honest good faith. I don?t know if greatest practices have emerged round things like that, however I’m sure that your job is clearly identified as a fair game. Each girls and boys feel the affect of only a second抯 pleasure, for the rest of their lives.

    Reply
  40. It’s amazing to pay a quick visit this website and reading the views of all mates
    concerning this piece of writing, while I am also zealous of getting familiarity.

    Reply
  41. Helpful info. Fortunate me I found your website accidentally, and I am stunned why
    this accident didn’t came about in advance! I bookmarked it.

    Reply
  42. Good post. I be taught one thing more challenging on totally different blogs everyday. It’ll at all times be stimulating to read content from different writers and follow a bit something from their store. I抎 choose to make use of some with the content on my blog whether you don抰 mind. Natually I抣l give you a hyperlink in your net blog. Thanks for sharing.

    Reply
  43. Spot on with this write-up, I actually think this web site needs rather more consideration. I抣l most likely be once more to learn far more, thanks for that info.

    Reply
  44. Thanks for your personal marvelous posting! I certainly
    enjoyed reading it, you may be a great author.I will always bookmark your blog
    and will eventually come back in the foreseeable future.
    I want to encourage you continue your great posts, have a nice weekend!

    Reply
  45. Having read this I thought it was really enlightening. I appreciate you finding the
    time and effort to put this content together.

    I once again find myself spending a lot of time both reading and posting comments.
    But so what, it was still worth it!

    Reply
  46. I am in fact happy to glance at this website posts which consists
    of tons of helpful data, thanks for providing these information.

    Reply
  47. I know this web page gives quality dependent content and extra information, is there any other web page
    which provides these kinds of stuff in quality?

    Reply
  48. I’m truly enjoying the design and layout of your website.
    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit
    more often. Did you hire out a developer to create your theme?
    Superb work!

    Reply
  49. Does your site have a contact page? I’m having trouble locating it but, I’d like to send you an e-mail.
    I’ve got some ideas for your blog you might
    be interested in hearing. Either way, great website
    and I look forward to seeing it improve over time.

    Reply
  50. These are really great ideas in regarding blogging. You have touched some good points
    here. Any way keep up wrinting.

    Reply
  51. I simply want to tell you that I am just beginner to blogs and truly liked you’re web-site. Likely I’m planning to bookmark your site . You surely have superb well written articles. Thanks for sharing your webpage.

    Reply
  52. You can definitely see your expertise in the paintings you write. The world hopes for more passionate writers like you who are not afraid to mention how they believe. All the time go after your heart. “We are near waking when we dream we are dreaming.” by Friedrich von Hardenberg Novalis.

    Reply
  53. Hi! This is my first comment here so I just wanted to give a quick shout out and tell you I truly
    enjoy reading your blog posts. Can you suggest any other blogs/websites/forums
    that go over the same topics? Thanks a lot!

    Reply
  54. Hi, i think that i saw you visited my website so i came to “return the favor”.I’m attempting to find things to improve my site!I suppose its ok to use some of your ideas!!

    Reply
  55. I do not even know how I ended up here, but I thought this post was great.
    I do not know who you are but definitely you’re going to
    a famous blogger if you aren’t already 😉 Cheers!

    Reply
  56. When someone writes an paragraph he/she keeps the image
    of a user in his/her mind that how a user can be aware of it.
    So that’s why this post is great. Thanks!

    Reply
  57. Thank you for shaaring excellent informations. Your web site iis very cool.
    I am impressed by the details that you’ve on this site.
    It reveals how nicely you perceive his subject.
    Bookmarked this web page, will come back for more articles.
    You, my pal, ROCK! I found simply the information I already searched all over the place and jus could not come across.

    What a perfect website.

    Reply
  58. Hello, i think that i saw you visited my website thus i came to “return the favor”.I’m trying to find things to enhance my web site!I suppose its ok to use some of your ideas!!

    Reply
  59. Good info and right to the point. I am not sure if
    this is actually the best place to ask but do you folks have any thoughts on where to get some professional writers?
    Thx 🙂

    Reply
  60. Why users still make use of to read news
    papers when in this technological globe everything is presented on web?

    Reply
  61. Ahaa, its pleasant discussion about this paragraph here at this
    web site, I have read all that, so now me also commenting here.

    Reply
  62. Excellent pieces. Keep posting such kind of information on your page.
    Im really impressed by your blog.
    Hey there, You have done an incredible job. I’ll certainly digg
    it and individually recommend to my friends. I’m confident they will be benefited from this website.

    Reply
  63. Great web site you have got here.. It?s difficult
    to find quality writing like yours these days.
    I really appreciate individuals like you! Take care!!

    Reply
  64. Hello There. I found your blog using msn. This is an extremely well written article.
    I’ll make sure to bookmark it and come back to read more of your
    useful information. Thanks for the post. I’ll definitely comeback.

    Reply
  65. I was looking through some of your blog posts on this internet site and I conceive this web site is rattling informative ! Keep on posting . eegeedkbgfdd

    Reply
  66. GooԀ day! Would yοu mind if I share youг blog with mу twitter group?
    Therе’s a lot of folkѕ that І think would really enjoy your cоntent.
    Please let me know. Many thanks

    Reply
  67. Great goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic.
    I actually like what you’ve acquired here, certainly like what you are stating
    and the way in which you say it. You make it enjoyable and you still care for to keep it smart.
    I cant wait to read much more from you. This is really a tremendous web site.

    Reply
  68. Thanks for the good writeup. It in truth used to be a entertainment account
    it. Glance complicated to more introduced agreeable from you!
    By the way, how can we communicate?

    Reply
  69. Fantastic goods from you, man. I have understand your stuff previous to and you’re just extremely
    wonderful. I really like what you’ve acquired here,
    really like what you’re stating and the way in which you say it.

    You make it enjoyable and you still care for to keep
    it wise. I cant wait to read much more from you. This is actually
    a tremendous website.

    Reply
  70. For most up-to-date information you have to go to
    see internet and on internet I found this web site as
    a most excellent web page for latest updates.

    Reply
  71. Thank you for every other magnificent article. Where else may anyone get that
    type of information in such an ideal means of writing?
    I have a presentation next week, and I’m on the look for such information.

    Reply
  72. Hello there, just became aware of your blog through Google, and found that
    it’s truly informative. I’m going to watch out for brussels.
    I will be grateful if you continue this in future. A lot of people
    will be benefited from your writing. Cheers!

    Reply
  73. I enjoy, lead to I found just what I was having a look for.
    You have ended my 4 day lengthy hunt! God Bless you man. Have a great day.

    Bye

    Reply
  74. Great web site. Plenty of helpful info here.
    I’m sending it to some friends ans additionally sharing in delicious.
    And naturally, thanks on your effort!

    Reply
  75. Thank you, I have just been looking for information approximately this
    subject for a long time and yours is the greatest I’ve discovered so far.

    But, what about the conclusion? Are you positive in regards to the supply?

    Reply
  76. Good post. I learn something totally new and challenging on blogs
    I stumbleupon everyday. It will always be helpful to read articles from other writers and practice a little something from other websites.

    Reply
  77. These are really wonderful ideas in about blogging. You have
    touched some fastidious points here. Any way keep up wrinting.

    Reply
  78. I every tіme emailed this web site post page to all my friеnds, becauѕe if like to read it after that my
    friends will too.

    Reply
  79. This is really interesting, You’re a very skilled blogger.

    I have joined your feed and look forward to seeking more of
    your wonderful post. Also, I’ve shared your website in my social networks!

    Reply
  80. Just wish to say your article is as amazing.
    The clarity for your publish is just excellent and i could think you’re
    a professional in this subject. Fine with your permission allow me to grasp your RSS
    feed to stay updated with imminent post. Thank you 1,000,000
    and please keep up the gratifying work.

    Reply
  81. My brother recommended I might like this web site.

    He was totally right. This post truly made my day.

    You cann’t imagine simply how much time I had spent for this info!
    Thanks!

    Reply
  82. Incredible! This blog looks exactly like my old one! It’s
    on a completely different topic but it has pretty much the same page layout and design. Excellent choice of
    colors!

    Reply
  83. Excellent post but I was wanting to know if you could write a
    litte more on this topic? I’d be very thankful if you could elaborate a little bit more.
    Bless you!

    Reply
  84. Great article and right to the point. I don’t know if this is really the best place to ask but do you guys have any ideea where
    to employ some professional writers? Thanks 🙂

    Reply
  85. I’m really enjoying the design and layout of your blog.
    It’s a very eassy on thhe eyes whichh makes it much more enjoyable for me to cme here and visit more often.
    Did you hire out a developer to create your theme?
    Fantastic work!

    Reply
  86. May I just say what a relief to find somebody that
    really understands what they’re discussing online. You certainly realize how to bring a problem
    to light and make it important. A lot more people ought to look at this
    and understand this side of your story. It’s surprising you are not more popular given that you definitely have
    the gift.

    Reply
  87. I am really glad to glance at this website posts which includes plenty of helpful data, thanks for providing these kinds of
    data.

    Reply
  88. This is a great tip particularly to those new to the blogosphere. Brief but very precise information… Many thanks for sharing this one. A must read article!

    Reply
  89. Hmm is anyone else experiencing problems with the images on this blog loading?
    I’m trying to figure out if its a problem on my end or if it’s the blog.

    Any responses would be greatly appreciated.

    Reply
  90. You can definitely see your skills within the work you write.
    The sector hopes for more passionate writers like you
    who aren’t afraid to mention how they believe.
    All the time follow your heart.

    Reply
  91. My brother recommended I might like this blog. He was entirely right.
    This post actually made my day. You cann’t consider just how a
    lot time I had spent for this info! Thank you!

    Reply
  92. Thanks a lot for sharing this with all people you actually recognise what you’re talking approximately!

    Bookmarked. Please additionally discuss with my site =).
    We will have a hyperlink trade contract between us

    Reply
  93. Very great post. I simply stumbled upon your weblog and wished to say that I have truly loved surfing
    around your weblog posts. After all I’ll be subscribing for your
    feed and I’m hoping you write once more soon!

    Reply
  94. I love your blog.. very nice colors & theme.

    Did you design this website yourself or did you hire someone to do it for you?

    Plz answer back as I’m looking to create my own blog
    and would like to know where u got this from.
    kudos

    Reply
  95. Great goods from you, man. I’ve understand your stuff previous to and you are just too excellent. I actually like what you have acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I cant wait to read far more from you. This is really a great website.

    Reply
  96. Great post. I was checking continuously this blog and I am impressed!
    Extremely helpful information particularly the last part
    🙂 I care for such information a lot. I was looking for this particular info for a long time.
    Thank you and best of luck.

    Reply
  97. Hi there everyone, it’s my first pay a quick visit at this web page,
    and paragraph is actually fruitful in support of me, keep up posting these
    articles or reviews.

    Reply
  98. We are a group of volunteers and opening a new scheme
    in our community. Your websie offered us with valuable info to work on. You’ve done a formidable job and ourr whole community will be thankful to you.

    Reply

Leave a Comment