WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from stackoverflow.com Oct 10 '11 at 11:12

This question came from our site for professional and enthusiast programmers.

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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