WordPress Widget-Areas with Description

Using WordPress version 2.9, there is now a possibility that we can write more detailed description for the widget areas. This is especially interesting when you define different widget areas, depending of categories or because the theme author defines various widget areas, that allows adjustments in more areas than just the sidebar. I do this for example in the theme Greyfoto, where the footer area is also equipped with widgets.

In the following example code we define a widget area, called My Lorem Ipsum Sidebar, which contains „detailed“ information.

if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
        'name' => 'My Lorem Ipsum Sidebar',
        'description' => __('Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'your_textdomain'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
}

wp-widgets

A more comprehensive example with two widget areas, one area for the sidebar and an area for the footer.

if ( function_exists('register_sidebar') ) {
    register_sidebar(array(
        'id' => 'sidebar',
        'name' => 'My Lorem Ipsum Sidebar',
        'description' => __('Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'your_textdomain'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));

    register_sidebar(array(
        'id' => 'footer',
        'name' => 'My Lorem Ipsum Footer',
        'description' => __('Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'your_textdomain'),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));
}

This may be used as follows in the templates, it's being used in the footer.php of the widget area My Lorem Ipsum Footer.

<div id="footer">
    <ul>
        <?php dynamic_sidebar('footer'); ?>
    </ul>
</div>

Comments are closed.

4 comments

  1. Markus

    danke für den tip
    Thanks for the tip

    Merry Christmas

  2. Matt Bridges

    Oh, beautiful. I have been having trouble figuring out exactly how to implement individual sidebars. Great tip!

  3. Mibaster

    Awesome, and easy! Thanks for sharing.

  4. kyle

    i had no idea i could add descriptions - lovely!
    ~k~