2

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

2

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

| improve this answer | |
  • it seems to work but now I have the following problem: if (for example) I reneam 'partner-slide' as 'partner-slide-2' (in all occurrences: in the index.php and in functions.php) don't work...why? – AndreaNobili Feb 7 '14 at 18:12
  • It will as long as they match. Clear your browser cache and populate the widgets again in the Widgets admin area. – Brad Dalton Feb 7 '14 at 18:17
  • I think that I have understand by myself what was the problem: simply I have to reload the backend section in wich I insert the widget voices after that I change the id value – AndreaNobili Feb 7 '14 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.