Create Custom Widget

‘about_us_widget’, // your unique widget id
‘About Us’, // widget name
‘about_us_widget_display’, // callback function to display widget
array( // options
‘description’ => ‘Description of what your widget does’

‘about_us_widget’, // id
‘about_us_widget’, // name
‘about_us_widget_control’ // callback function

function about_us_widget_control($args=array(), $params=array()) {
//the form is submitted, save into database
if (isset($_POST[‘submitted’])) {
update_option(‘about_us_widget_title’, $_POST[‘widgettitle’]);
update_option(‘about_us_widget_twitterurl’, $_POST[‘twitterurl’]);
update_option(‘about_us_widget_description’, $_POST[‘description’]);

//load options
$widgettitle = get_option(‘about_us_widget_title’);
$twitterurl = get_option(‘about_us_widget_twitterurl’);
$description = get_option(‘about_us_widget_description’);

Widget Title:

Twitter Profile URL:


function about_us_widget_display($args=array(), $params=array()) {
//load options
$widgettitle = get_option(‘about_us_widget_title’);
$description = get_option(‘about_us_widget_description’);
$twitterurl = get_option(‘about_us_widget_twitterurl’);

//widget output
echo stripslashes($args[‘before_widget’]);

echo stripslashes($args[‘before_title’]);
echo stripslashes($widgettitle);
echo stripslashes($args[‘after_title’]);

echo ‘

‘.stripslashes(nl2br($description));if ($twitterurl != ”) {
echo ‘

Follow us on Twitter


echo ‘

‘;//close div.textwidget
echo stripslashes($args[‘after_widget’]);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s