[wp-hackers] map function to all sites?

Andrew Nacin wp at andrewnacin.com
Fri Jan 28 22:00:21 UTC 2011


On Fri, Jan 28, 2011 at 4:56 PM, Wei Hsu <wei at hyperinkpress.com> wrote:

> Hi, I'm trying to map a function to apply to all the sites in my multisite
> network. Is there a standard way of doing that?
>
> For example, let's say I'm trying to change the theme for all my sites at
> once. I'd love to be able to do something like:
>
> foreach (all_sites() as $site) {
>     $site->switch_theme('thesis_18', 'thesis_18');
> $site->thesis_upgrade();
> }
>
> Thanks!
>
> Wei


Sure, just use switch_to_blog() with switch_theme(). It's going to be
intensive depending on the number of sites and may want to run it on a cron.

Nacin


More information about the wp-hackers mailing list