WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I enable specific themes and plugins for new blogs that have been created with wpmu_create_blog? I'd like to set the themes and plugins in code rather than having a person manually set them in the network administration section (i.e. not in http://domain/wp-admin/network/site-themes.php?id=xx).


Update: Actually I think I may have figured part of this out. wpmu_create_blog has a $meta property. This property can be set to an associative array with a key of 'allowedthemes'. That key's value should be set to an associative array with keys:values = 'theme-name-or-id':true. I still need to set the starting theme for this blog and set plugins, which must be similar. Is this even a good approach?

share|improve this question
up vote 2 down vote accepted

This WPSE answer led me to the $meta argument for wpmu_create_blog. That led me to this Support thread showing that $meta can include template and stylesheet arguments which seem to contain the folder name for the theme you want (just like the "Template" field in a child theme's style.css head section).

I'm having a hard time finding good documentation on wpmu_create_blog, but hopefully this is enough to work on.

share|improve this answer

You can use the following code to assign template and stylesheet to a sub site/blog:

// create the blog
$blog_ID = wpmu_create_blog( $domain, $path, $title, 1 );

// assign template and stylesheet to the blog
update_blog_option( $blog_ID, 'template', 'your_template_name' );
update_blog_option( $blog_ID, 'stylesheet', 'your_stylesheet_name' );

This will assign the template and stylesheet to the blog that has been just created. Please visit the following link to see the documentation for wpmu_create_blog function.


Many thanks.

share|improve this answer
I gave the answer to @mrwweb because his answer was written first, but thanks for writing code. – getWeberForStackExchange May 15 '12 at 16:26
function mysite_wpmu_new_blog($blog_id)
    switch_theme('my-theme', 'my-theme');

add_action('wpmu_new_blog', 'mysite_wpmu_new_blog');

This works for me!

share|improve this answer
No need to post exactly the same answer two times. – toscho Nov 26 '12 at 12:11
sorry, i just want to make sure people do not miss the answers they need. – Wint Nov 27 '12 at 3:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.