in order to create a custom widget we need to extend the Wp_widget class in wordpress and we use 3 methods for creating and widget form,widget,update.form is backend ui of the widget and widget is used to display to frontend and update is used to update the widget field values.Two approaches can be used to create widget
1:creating widget as plugin
2:add code to functions.php
Here i created widget as plugin
basic skelton
1:creating widget as plugin
2:add code to functions.php
Here i created widget as plugin
basic skelton
class wiget_name extends Wp_widget
{
function widget()
{
parent::WP_Widget(false, $name = __('widget name', 'wp_widget_plugin') );
}
public function update($new,$old)
{
//updates the widget field
}
public function form($instance)
{
//ui creation
}
public function widget($arg,$instance)
{
//front end display
}
}