最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Trying to change active theme on all sites in Multisite

programmeradmin7浏览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!!!

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!!!

Share Improve this question asked Nov 18, 2015 at 0:18 George BGeorge B 13 bronze badges 2
  • Related: wordpress.stackexchange/questions/54543/… – Jesse Nickles Commented Oct 24, 2022 at 11:56
  • Does this answer your question? Changing Multisite themes on mass – Jesse Nickles Commented Oct 24, 2022 at 12:09
Add a comment  | 

1 Answer 1

Reset to default 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(); }

发布评论

评论列表(0)

  1. 暂无评论