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

[code type=php]

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”);’));

[/code]

 

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

Leave a Reply to Tamil Arasan Cancel reply

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