How to Create Widget in WordPress using PHP Code

By | January 20, 2014

Widget in wordpress will be more helpful for non-developer, widget can be create easily with simple steps. Widgets are the important advantage in wordpress, . Here is the tutorial for how to create widget in wordpress using php code.

function freeze_plugin() - this function will create the widget name as “Freeze Widget”

function form() - this function will be used to display the content to Admin area

function widget() - this function will be used to display the content to visitor area

 

Add the below coding into your functions.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class freeze_plugin extends WP_Widget
{
function freeze_plugin()
{
parent::WP_Widget(false, $name = __('Freeze Widget', 'freeze_plugin') );
}
function form()
{
echo "<b>This is sample widget</b>";
}
function widget()
{
echo "<b>This is sample widget</b>";
}
}
add_action('widgets_init', create_function('', 'return register_widget("freeze_plugin");'));

 

One thought on “How to Create Widget in WordPress using PHP Code

Leave a Reply

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

tawse-reductive