1

Where should a plugin ideally hook to call register_sidebar();?

Will init do just fine?

function my_plugin_register_sidebars() {
    $args = array(
        'name' => 'foo'
        'description' => 'bar'
        ...
    );
    register_sidebar( $args );
}
add_action( '**????**', 'my_plugin_register_sidebar' );
5

Twenty Eleven and Twenty Twelve use the widgets_init action. Given that these themes are generally considered to use best practices for theme development, I think this hook would be ideal.

0
add_action( 'init', 'my_plugin_register_sidebar' );

Edit: @Brasofilo - the init is used to register menus, I figured it could also be used to register other stuff. I could be wrong though since I don't develop themes. An explanation of why using "init" is wrong would help me in the future. http://codex.wordpress.org/Navigation_Menus

  • Can you give a reference for using this hook? The Codex points to this article that indicates widgets_init... – brasofilo Jul 22 '12 at 17:31

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.