[wp-hackers] Widgets that load at the same time as a theme is selected

Andy Skelton skeltoac at gmail.com
Sat Aug 9 14:47:33 GMT 2008

On Sat, Aug 9, 2008 at 2:11 AM, Alister Cameron
<alister at alistercameron.com> wrote:
> Specifically I'm wanting to hook some "actions" together: when a theme is
> installed I want to be able to add into the "init" event some way to
> populate text widgets with some content and push them into a widget block
> (sidebar).

Take a look at the options rows that hold the widget configuration.
You can modify those.

The trick is in knowing when the theme has just been activated. Plugin
activation comes with a customized action but themes aren't treated
that way. In your theme's functions.php do:

if ( is_admin() && !get_option('mythemeisinstalled') ) {
  // set up the widgets here

  add_option('mythemeisinstalled', true);

Absolutely no warranties. :-)


More information about the wp-hackers mailing list