How to create a WordPress custom widgets?

Introduction of WordPress 2.8 for blog – o – sphere given user to more flexibility to publish data according to our need. WordPress 2.8′s new widget class allows the user to create custom widget. In this tutorial I will take you through various steps of setting up a widget in wordpress.

What can you learn from example custom widget?

Our example will tell you how to show a particular page in your widget area. Control will allow you to input all the necessary form data to give necessary out put.

custom widget wordpress

How will custom widget look in your dashboard?

Register the widget:

WordPress provides the widgets_init action hook that will allow us to register a widget

add_action('widgets_init', create_function('', 'return register_widget("custom_page");'));

Setting up of widget:

WordPress 2.8 allows you to create custom widget by simply extending WP_Widget class. Hence, first start creating a widget class by extending WP_Widget.

class custom_page extends WP_Widget {

}
(more…)