Is there a way to automatically register widgets when a new site is registered with a multi site setup? E.g. inside wpmu_new_blog?

2 Answers 2


In your themes functions.php file you can check wether or not it get's installed for the first time on that blog. This can be done by using an option. An option can be set to flag that it's installing.

This option that signals that an install is immanent can be used in a hook of the init jointcut so to flag for automatic widget registration. Widgets can be registerd with wp_set_sidebars_widgets(). After that's done, kill the flag.

Keep in mind that switching themes kills the widgets configuration. So this is for first-time use only.

A full working example on how to register widgets on theme activation can be found in the Semiologic Reloaded Theme. It's available for download, feel free to suit yourself.

  • @hakre - Your hyperlink is broken. Aug 28, 2010 at 18:05
  • @hakre - Also, maybe give a working example? If so, you'll answer less questions but they will be more helpful and thus more people will rate your answers highly. Lots of questions answered with only a little direction provided is less useful than fewer questions answered but answered well. When you answer every question with short answers it sometimes causes others to think "Why bother answering, @hakre already has?", at least that's how I sometimes feel. Aug 28, 2010 at 18:12
  • Okay, I see, will take some care on that.
    – hakre
    Aug 28, 2010 at 19:51
  • Actually I ended up just modifying the sidebar.php to provide the correct default widgets if no dynamic_sizebar was set. This was good enough for me, but thanks for your more generic solution.
    – grm
    Sep 1, 2010 at 8:08
  • Oh okay, it was not clear to me that this would be already fitting for you.
    – hakre
    Sep 1, 2010 at 13:52

Much easier. There's the_widget() function already present. Just consult the codex.

  • Kaiser: Not really the same thing, is it? The former registers the widget. All you're doing it is calling it. What if I have someone that doesn't want the widget anymore and has no idea how to edit the_widget code?
    – user4329
    Mar 30, 2011 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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