How to register_sidebar() without messing up the order?

How do you register a sidebar in a plugin without screwing up the pre-existing registered sidebars? (The ordering of the sidebar registrations, rather than the assigned ID, determines the sidebar data.)

1 Answer
1

function self_deprecating_sidebar_registration(){
  register_sidebar( /* Your arguments here */ );
}

add_action( 'wp_loaded', 'self_deprecating_sidebar_registration' );

Most themes will register the sidebar in their functions file, which is included before init but after plugins are loaded. Hooking onto wp_loaded should guarantee that your sidebar is registered after the theme’s.

Leave a Comment