4

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.)

9
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.

  • I should also add that wp_loaded is the latest hook you can reliably use to register the sidebar for both admin and front end. – John P Bloch Oct 4 '10 at 16:46
  • Sick. I was about to look up that same information. Thanks! – Dan Gayle Oct 4 '10 at 17:21
  • Also, can we get some action on this? core.trac.wordpress.org/ticket/14256 – Dan Gayle Oct 4 '10 at 17:24
  • If you can, attend the IRC dev chat on Thurs and mention the ticket. Or email a core dev. Or bring it up on the wp-hackers list. – EAMann Oct 4 '10 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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