WordPress – Making a widget (part 1)
Deprecated: Function create_function() is deprecated in /home/vhosts/poweredbygnulinux.com/wp-content/plugins/codecolorer/lib/geshi.php on line 4698
A widget is a special type of plugin. We will place our plugin in a sidebar.
This is our plan:
1. Create a function that will display the widget content.
2. Register that function as a widget using WordPress API.
3. To enable the widget you need to activate it now in the administration panel.
Like we made in previous examples , lets create a folder , and a php file.
Plugin Name: WP First Widget
Description: Our first widget
Author URI: http://www.
Plugin URI: http://www.
We will add an easy widget function , but only for starting . This will be the funcion that will work , but for now , only will say “hello world!”.
echo "Hello World!";
Then, we will add another function to register the widget :
// register widget
register_sidebar_widget('WP Wall', 'WPWall_Widget');
Then we must make the “hook” .
The action hook init executes just after WordPress has finished loading. It is a good choice for inserting general plugin initialization code such as registering widgets. We use it to insert our init
Now enable our plugin. Our widget will appear on the widgets page of the administrative panel. In order to make it active, you need to drag and drop it onto the sidebar.
Then we will see our “hello world!” in the sidebar: