duplicate sidebar

I have a problem with a sidebar. I have 4 sidebars: “Essential”, “Essential+”, “Premier” and “Premier+”.

register_sidebar(
     array(
         'name'          => __('Essential Plan'),
         'before_widget' => '<ul>',
         'after_widget'  => '</ul>',
         'before_title'  => '',
         'after_title'   => ''
    )
);
register_sidebar(
    array(
         'name'          => __('Premier Plan'),
         'before_widget' => '<ul>',
         'after_widget'  => '</ul>',
         'before_title'  => '',
         'after_title'   => ''
    )
);
register_sidebar(
    array(
         'name'          => __('Essential+ Plan'),
         'before_widget' => '<ul>',
         'after_widget'  => '</ul>',
         'before_title'  => '',
         'after_title'   => ''
    )
);
register_sidebar(
    array(
         'name'          => __('Premier+ Plan'),
         'before_widget' => '<ul>',
         'after_widget'  => '</ul>',
         'before_title'  => '',
         'after_title'   => ''
    )
);

I have to render “Premier” and “Premier+” in the same page. When I do this WordPress renders the same content for both pages, how can i fix this?
why is this happening?

1 Answer
1

Try giving a unique ID to each dynamic sidebar, via the id parameter passed to register_sidebar():

register_sidebar(
        array(
             'id'            => 'essential',
             'name'          => __('Essential Plan'),
             'before_widget' => '',
             'after_widget'  => '',
             'before_title'  => '',
             'after_title'   => ''
        )
    );

    register_sidebar(
        array(
             'id'            => 'premier',
             'name'          => __('Premier Plan'),
             'before_widget' => '',
             'after_widget'  => '',
             'before_title'  => '',
             'after_title'   => ''
        )
    );

    register_sidebar(
        array(
             'id'            => 'essential-plus',
             'name'          => __('Essential+ Plan'),
             'before_widget' => '',
             'after_widget'  => '',
             'before_title'  => '',
             'after_title'   => ''
        )
    );

    register_sidebar(
        array(
             'id'            => 'premier-plus',
             'name'          => __('Premier+ Plan'),
             'before_widget' => '',
             'after_widget'  => '',
             'before_title'  => '',
             'after_title'   => ''
        )
    );

And then call each one by ID:

dynamic_sidebar( 'essential' );
dynamic_sidebar( 'premier' );
dynamic_sidebar( 'essential-plus' );
dynamic_sidebar( 'premier-plus' );

Though, you should be able to call them via name or ID:

dynamic_sidebar( 'Essential Plan' );
dynamic_sidebar( 'Premier Plan' );
dynamic_sidebar( 'Essential+ Plan' );
dynamic_sidebar( 'Premier+ Plan' );

…unless the “+” gets sanitized from the parameter?

Leave a Comment