Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top