Justin Tadlock

Sidebar (widget area) descriptions in WordPress 2.9

Have you ever used a WordPress theme with more than a couple of widget areas? More specifically, have you ever used a WordPress theme with loads of widget areas and no idea how they all worked within the theme?

If you’ve ever used a theme of mine, you know I love adding widget areas everywhere. And, I know this can be confusing for some people.

Fortunately, WordPress 2.9 will allow theme developers to add a description for each widget area. This should help end users figure out what the heck is going on.

Widget descriptions from a user’s view

If you’re an end user and your theme author has added descriptions, you’ll see the description near the top of the widget area on the Widgets admin screen.

Widget Area Descriptions

Adding descriptions to widget areas

If you’re a theme developer, adding descriptions to your widget areas is as simple as adding an extra argument to the register_sidebar() function. Use the below PHP code as a guide.

add_action( 'init', 'register_my_widget_areas' );

function register_my_widget_areas() {

    register_sidebar( array(
        'name' => __('Primary', 'example'),
        'id' => 'primary',
        'description' => __('The main widget area, most often used as a sidebar.', 'example'),
        'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>'
    ) );
}

The new code allowed in 2.9 is the description argument.

'description' => __('The main widget area, most often used as a sidebar.', 'example'),

Theme authors, it’s time to implement this new feature for your users. It will take less than five minutes to add to your theme and should at least cut back on a few support queries.