I’m wild about WordPress Widgets!
In templating for Wordpress I’ve really come to appreciate the versatility that Wordpress Widgets offer to a website, so much so that I’m wishing there were more than 9 text widgets! Actually, there can be. You simply have to create more. See below.
If, when templating, you create a number of widgetized areas, and name them according to the place where they’ll show, and which template they’ll show in, you can easily create a site that has multiple areas that are editable. This is especially useful with WordPress Page custom templates.
Many plugins these days also offer one or two widgets as part of what they do. For instance, the NextGen Gallery plugin has both a thumbnail widget, which shows random thumbs from your photo galleries, and a slideshow widget, which rotates through all your images in a slideshow type presentation.
If you’re creating a widgetized area that can only take a certain type of content, you can use the functions.php file to dictate what code will be generated. For instance, to create a widget area named TopRight, that doesn’t live in a “list”, you use this in your functions file:
‘, ‘,
register_sidebar(array('name'=>'TopRight',
'before_widget' => '
‘before_title’ => ‘
‘,
‘after_title’ => ‘
));
This gives you a widget area, named TopRight, that is wrapped in a div, and which has an h2 header with the class TopRightTitle.
You can also assign a widget to a page, either as a separate widget area or you can add conditionals to your template. For instance, if there are widget areas you want to show conditionally, then this goes in your sidebar:
< ?php
//default
$sidebar_index=1;
//posts
if(is_single()) {
$sidebar_index=2;
}
//navigation pages
if( is_page('archives') || is_search() || is_404() ) > 0) {
$sidebar_index=3;
}
?>
Now, you’ve found out how versatile widgets can be, you need more than 9 text widgets, huh? That’s simple. Create your own widgets.
Technorati Tags: WordPress Widgets, WordPress Theme Design, WordPress Configuration








