Using Widgets

Widgets offer a powerful way to change up your site without touching a line of code. WordPress comes with a baker's dozen of built-in widgets. You can download many more from the plugin repository, and some themes come with their own widgets. Figure 6-1 shows the basic widgets you'll find under Appearance ^ Widgets.

Testing Trunk ^.«ro.

1, nimm 1 lu/bo Um Out l

" Widgets

" Widgets

AvllllHc r-1

Figure 6-1. The widget management screen

On the main page, you'll see a bank of available widgets. Below the available widgets, there's another bank of inactive widgets. On the right, you'll see a drop zone for each sidebar—that is, each widget area defined in your theme, regardless of whether they actually appear on the sides. The number of sidebars varies; some themes have just one, while others (like Twenty Ten) have five or six. Sidebars can include descriptions to help you keep track of which is which, but the description is optional, as you'll see in Chapter 7, and not all theme or plugin authors will include them.

Figure 6-2. Dragging widgets into place

To get started, drag a widget from the available bank into one of the sidebars, as shown in Figure 6-2. Once you've placed the widget in the sidebar, the widget options screen will open. Some widgets don't have any options, and all you can do is close the options screen or remove the widget. (You can also remove widgets from the sidebar by dragging it elsewhere, either back to the available area or into the inactive bank). Other widgets have some options that let you customize their display. For example, the category widget lets you turn the plain linked list into a dropdown, or show the categories in nested lists reflecting the parent/child hierarchy, or include the number of posts assigned to each category. Once you've changed the options, be sure to press the Save button. Otherwise, your changes will be lost when you leave the widget manager screen.

When you drag a widget to the inactive area, it will no longer be displayed in your theme, but all its settings will be preserved. This is useful when you want to temporarily disable a widget or try out an alternative without losing your previous work. When you change your theme, all the active widgets you were using will be moved to the inactive area. All their settings will be saved, so all you have to do is drag them back into the appropriate sidebars in your new theme.

WordPress 2.8 introduced a new way of creating widgets. Any widgets created using the new API, including all the default widgets, can be used as many times as you want. Some older plugins and themes might not use the new multiwidget features, and their widgets can be used only once.

You'll learn how to create your own widgets in Chapter 8.

0 0

Post a comment