So I have a plugin that I've created for the admin are when creating post... and I'd like to supply a widget along with it.

I'm trying to figure out the best way to initialize my widget. I'm initializing my plugin like so:

function call_menu_per_page_class() 
    return new MenuPerPage();
if ( is_admin() )
    add_action( 'admin_menu', 'call_my_class' );

Obviously, the widget does NOT require someone to be an admin to view it... it will be viewed in a sidebar within my Theme.

Is there a specific action/filter and hook that I should use to execute my widget class?

Remember, this is being packed with my plugin... so it can't be called from functions.php

1 Answer 1


According to Codex register_widget() should be hooked to widgets_init.

Hook into init then and at that point hook further different methods to appropriate hooks later.

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.