How to Add Widget Areas to Your WordPress Template Files - dummies

How to Add Widget Areas to Your WordPress Template Files

By Lisa Sabin-Wilson

About 99.99 percent of the WordPress themes available are coded with widgetized sidebars. This coding means that you can use the widgets within WordPress to populate your sidebar area with content, navigation menus, and lists. Follow these steps to call widgets to your site:

  1. On your Dashboard, choose Appearance→Editor.

    The Edit Themes page opens.

  2. Click the Sidebar (sidebar.php) template in the list on the right side of the page.

    The Sidebar template opens in the text box in the middle of the page.

  3. Type the following code in the Sidebar (sidebar.php) template:

    <ul id=”sidebar”>
    <?php if ( ! dynamic_sidebar( 'Primary Widget Area' ) ) : ?>
    <?php endif; ?>

    The parameter within the dynamic_sidebar template tag corresponds to the name that you provided in the ‘name’ widget array. This example uses the ‘Primary Widget Area’. The name you use must be the same one that you used before; otherwise, it won’t appear on your website.

  4. Click the Update File button.

    The changes you’ve made to the Sidebar (sidebar.php) template file are saved.

You can register an unlimited number of widgets for your theme. This flexibility allows you to create several widgetized areas and widget features in different areas of your site.