Create a WordPress widget plugin How to create a widget Plugin in wordpress

WordPress is an amazing CMS with a couple of features Widgets are the one of them . So today i am going to explain how to create a wordpress widget plugin .

A wordpress widget consists of four major things .
1) constructor : This will initialize the widget . It is the part which defines the name of the widget .
2 form(): is the function which contains the form at the admin end .
3) pdate(): function to save the content in the form .As WordPress core developers added a really powerful widgets API, we only need to add this code to update each field
4)Widget(): function to display the saved content in the front end . This function can be customize with css and html tags according to the theme or requirements
To create a wordpress plugin we need to insert the predefined set of code in the plugins main file . Which contains the information about your plugin .

create a class to initialize your widget like .

Create a function form(). to create a form in the admin section like given below

this code will create a widget in the admin section with a form containing a text field , a textarea and a dropdown list . Now we need to save the content . so create a function widget() like given below.

this function will save the values of your widget form . and now you can display the fields with widget() function