Advertisement

Add Widget Areas to Your WordPress Template Files

Most of the content you want to add into your sidebar can be accomplished with WordPress widgets. Generally you don't need to mess around with the code in the sidebar.php template file.

Follow these steps to call widgets to your WordPress website (these steps assume the widget code isn’t already in the Sidebar template):

  1. In 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; ?>
    </ul>

    The parameter within the dynamic_sidebar template tag corresponds to the name that you provided in the 'name' widget array earlier in this section. This example uses 'Primary Widget Area'. The name you use must be the same one that you used earlier; otherwise, it won’t display 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.

blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com