• Hi, I noticed a kind of annoying bug and wanted to know if it had been reported or if it can be fixed in later versions of WordPress.

    I code my own themes from HTML –> WordPress.

    Let’s say I create 3 widget positions in functions.php and then I go and add some widgets in the WordPress admin section.

    Later on I decide I want to create another widget position in functions.php … If I add this new widget positition to the top or the middle of the existing widget positions, then when I go back to the widget manager in wordpress, it actually shifts all my widgets around so that things assigned to Widget Position 1 get moved to Widget Position 2, etc… The only way around this is to add the new widget position as the last one being declared in functions.php .

    I know the easy solution is to just add it to the end, but this is still kind of annoying. Widgets should stick to the assigned position regardless of how many new ones are created.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Are you using unique names/ids for your widgets? eg:

    function my_widgets_init() {
    	register_sidebar(array(
    		'name'=> __('One'),
    		'id' => 'widget-one',
    		'description' => __('Main menu'),
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    	));
    	register_sidebar(array(
    		'name'=> __('Two'),
    		'id' => 'widget-two',
    		'description' => __('Main menu'),
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2 class="widgettitle">',
    		'after_title' => '</h2>',
    	));
    }
    add_action( 'widgets_init', 'my_widgets_init' );
    Thread Starter serialboxhpc

    (@serialboxhpc)

    thanks for the reply.

    hmm not ID’s but names yes.

    stripped down they look like this:

    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'Newsletter',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    ));
    
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'Tombstone',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    ));
    
    if ( function_exists('register_sidebar') )
    register_sidebar(array(
    'name' => 'featured',
    'before_widget' => '',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>',
    ));

    So if I add an ID to each one, then the widget items I place in there won’t shift when adding new widgets?

    To be honest, I’ve never set widgets up without ids. But then I’ve never had the problem that you’re having. So I’d suggest that you try it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug when adding new widget locations to a wordpress theme’ is closed to new replies.