I’ve registered some new sidebars. They are appearing on appearance->widgets screen. However, they appear in two columns and the order is arbituary. Is there a way to config the order and columns in the widget admin screen?
1 Answer
Sidebars are output in registration order, which is implicitly captured by how they are added to a $wp_registered_sidebars
global.
This can easily be manipulated, for example following code will move first
sidebar to the start:
add_action( 'register_sidebar', function ( $sidebar ) {
global $wp_registered_sidebars;
if ( 'first' === $sidebar['id'] ) {
$sidebar = $wp_registered_sidebars['first'];
unset( $wp_registered_sidebars['first'] );
$wp_registered_sidebars = [ 'first' => $sidebar ] + $wp_registered_sidebars;
}
} );
register_sidebar( [ 'name' => 'one', 'id' => 'one' ] );
register_sidebar( [ 'name' => 'two', 'id' => 'two' ] );
register_sidebar( [ 'name' => 'first', 'id' => 'first' ] );