Widgets not showing in my custom theme

I am developing this WordPress custom theme: http://onofri.org/WP_BootStrap and I am trying to insert a widget area under the Partner e Sostenitori section, but can’t work.

I have performed the following operations:

Read More

1) I have put the following code into the functions.php theme file:

/**
 * Register our sidebars and widgetized areas.
 *
 */
function arphabet_widgets_init() {

    register_sidebar(array(
        'name' => 'My_Widgtet_Area',
        'id' => 'partner-slide',
        'before_widget' => '<div>',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="rounded">',
        'after_title' => '</h2>',
    ));
}

add_action('widgets_init', 'arphabet_widgets_init');

As you can see the name of the widgetized area is My_Widgtet_Area

2) Then I have insert the following code into my index.php file to show the widgets in the desired positions:

<section id="partnerSlide">
    <header class="header-sezione">
        <h2>Partner e Sostenitori</h2>
    </header>
    <div class="row">
        <?php
            // 'My_Widgtet_Area' area, where the id is called:
            if (is_active_sidebar( 'My_Widgtet_Area' ) ) : ?>

            <div id="widget-sidebar">
                <ul>
                    <?php dynamic_sidebar( 'My_Widgtet_Area' ); ?>
                </ul>
            </div><!-- #widget-sidebar .widget-area -->

        <?php endif; ?>
    </div>
</section>

3) Then I entered in the WP administration panel and into the Appearance —> Widget section I have the My_Widget_Area “box” where I can drag the widgets in my wordpress installation. So I put in it some widget (as the Calendar and the Search wigets) to try it

The problem is that, as you can see in the previous link, the Partner e Sostenitori text is written but there is no widget displayed in my page.

Why? What am I missing? How can I solve this problem?

Tnx

Andrea

Related posts

1 comment

  1. You’re using the widget name and not i.d which is why it isn’t working.

    Change this:

    if (is_active_sidebar( 'My_Widgtet_Area' ) ) : ?>
    
            <div id="widget-sidebar">
                <ul>
                    <?php dynamic_sidebar( 'My_Widgtet_Area' ); ?>
                </ul>
    

    To this:

    if (is_active_sidebar( 'partner-slide' ) ) : ?>
    
            <div id="widget-sidebar">
                <ul>
                    <?php dynamic_sidebar( 'partner-slide' ); ?>
                </ul>
    

    The i.d in the template tag immediately above should match the i.d you use to register the widget in your functions file which in this case is partner-slide

    register_sidebar(array(
        'name' => 'My Widget Area',
        'id' => 'partner-slide',
    

    That’s one obvious problem and there may be others however you should follow the Codex as it provides working examples with related links http://codex.wordpress.org/Function_Reference/dynamic_sidebar

Comments are closed.