A quick guide to your custom widget for WordPress

Today in one of the support forums someone asked for a tutorial on adding your widgets to a static page on your WordPress CMS, and i couldn’t find a good straight forward tutorial to help him guide, so thought about writing it myself.
The problem?
You need a custom widget on your static homepage of your WordPress site and chances are generally people want to display recent posts, and after you Google around you would generally find some plugins which might help you with that. So just to avoid plugins and giving you more control of your widget.
Coding skills: (More than a basic beginner)
Locate your functions.php file in your theme folder
add a custom function
[sourcecode language=”plain”]
if ( function_exists(‘register_sidebar’) ) {


‘id’ => ‘default-sidebar’,

‘name’ => ‘Content 3 Column Sidebar’,

‘before_widget’ => ‘<div class="col %2$s" id="%1$s">’,

‘after_widget’ => ‘</div>’,

‘before_title’ => ‘<h2>’,

‘after_title’ => ‘</h2>’

Once this is added (and uploaded) you would see your custom widget area in appearance > widget with all other default widget sections.
Add what ever you want to use it for.
than go to your static theme page and create a DIV (or how so ever you want to wrap your sidebar(Widget))
Something like this
[sourcecode language=”plain”]
<div id="my-widget">
< ?php if (is_active_sidebar(‘default-sidebar’)) : ?>
That is all folks.

%d bloggers like this: