Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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?

share|improve this answer
    
i call them with the name! i guess is a problem with the + symbol, thanks for the ID advice, ill try it –  Rommel Castro A Nov 27 '12 at 18:59
1  
If the $index argument of dynamic_sidebar($index) is not an integer, the function calls sanitize_title(), which will turn Premier+ Plan into premier-plan. –  Johannes Pille Nov 27 '12 at 19:20
    
oh thanks, i didn't know that, so i guess my best option is use id –  Rommel Castro A Nov 27 '12 at 19:23
    
The thanks ought to address Chip, but other than that, yes, go with id. –  Johannes Pille Nov 27 '12 at 19:24
    
thank you guys! it worked –  Rommel Castro A Nov 27 '12 at 21:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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