0

I have all my sub sites using the same theme but want to change them all to something new.

I tried: define( 'WP_DEFAULT_THEME', 'your-theme-name' ); to see if that would change the active themes on all my sites but did not. Is that only supposed to set the default theme for all newly created sites and NOT existing sites?

I have a new theme network enabled, is there a way to activate that on ALL my sub sites at once and not manually one by one?

I am using the latest version of wordpess and tried deleting all my themes but the one I wanted to use thinking it would default to the only available theme. However, it was trying to use twentyfifteen and listed but had not info or screen shot, just a empty box so not sure what I did wrong.

Has to be a way :)

thanks!!!

2

1 Answer 1

1

Use switch_theme( 'theme_name' ) to switch a theme

Use wp_get_sites( array('network_id' => $wpdb->siteid) ) to retrieve all sites info including the blog_id

Loop through the retrieved blog ids and execute code within the scope of each blog using the switch_to_blog() function:

foreach( $blog_ids as $blog_id ){ switch_to_blog( $blog_id ); //Do stuff restore_current_blog(); }

1
  • Got that to work :) Now what we be even better is if there was a way to copy the themes settings to the existing sites as well. I have one site used as a template with the theme customized with a menu and site logo and all new sites created keep those theme settings. I use "new blog template" from wpmudev for that and it copies my pages, theme & setting to all new sites. However, when I active the them on existing sites I have to update the theme settings or "import" the theme settings which is too much work.
    – George B
    Commented Nov 18, 2015 at 21:51

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.