0
votes

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:

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

1
Have you tried to replace _ with - in "My_Widgtet_Area"?j.karlsson

1 Answers

0
votes

When you call the widget in the index.php you should use widget ID, not the name, name is displayed in the admin.

So correct code in index.php should be:

<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( 'partner-slide' ) ) : ?>

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

    <?php endif; ?>
</div>