Creating your own widgets in WordPress might seem like a complicated or confusing task but the truth is, it’s easier than you think!

In your the root of your theme directory (ex: wp-content/themes/default), you’ll find a file called “functions.php”, if you do not, create it.

Inside add:

if ( function_exists('register_sidebar') ) {
   register_sidebar(array("id" => "facts_and_stats",
			"name" =>"Facts and Stats"
   ));
}

(all attributes can be found here: http://codex.wordpress.org/Function_Reference/register_sidebar)

In the backend, under “appearance > widgets”, you’ll find all available widgets and all available sidebars. You can drag a widget into the sidebar and customize it.

Then in a template file in your theme, say your “index.php” file, you can call the content of this widget with the following block of code:

< ?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar("facts_and_stats") ) { } ?>

Widgets are wrapped in <li></li> by default, you can custom a group of them with a trick such as the following, where I remove all wrappers for multiple widgets by creating an array setting the before_ and afters_’s to nothing and merge it with the id and name info in another array I create inline.

$widget_args=array(
	'before_widget' => '',
	'after_widget' => '',
	'before_title' => '',
	'after_title' => '',
);

if ( function_exists('register_sidebar') ) {
   register_sidebar(array_merge($widget_args,array("id" => "facts_and_stats", "name" =>"Facts and Stats")));
   register_sidebar(array_merge($widget_args,array("id" => "report_card", "name" =>"Report Card")));
}

Another trick I I like to do is add a quick link on the frontend for to the edit page if the user is logged in an has rights to edit widgets:

<?php if (current_user_can('manage_options')) { echo '<a href="'.get_bloginfo('url').'/wp-admin/widgets.php" title="edit this widget">edit this widget</a>'; } ?>