Title: Activate theme programmatically
Last modified: August 20, 2016

---

# Activate theme programmatically

 *  Resolved [marlun](https://wordpress.org/support/users/marlun/)
 * (@marlun)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/activate-theme-programmatically/)
 * Hi,
 * I would like to know how I can automatically activate a theme when a new blog
   is created in a multisite installation.
 * Right now I’ve got this:
 * add_action(‘wpmu_new_blog’, ‘create_new_site’);
    function create_new_site($blog_id){
   switch_to_blog($blogid);
 *  // Do all the work
    switch_theme(‘marlun’, ‘marlun’);
 *  restore_current_blog();
    }
 * My theme is located in wp-content/themes and the stylesheet is called style.css.
   The theme is a reworked twenty eleven. However nothing happands when a new blog
   is created. If I go to the apearance tab in the new blog my theme is available
   but not activated.
 * -Martin

Viewing 1 replies (of 1 total)

 *  Thread Starter [marlun](https://wordpress.org/support/users/marlun/)
 * (@marlun)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/activate-theme-programmatically/#post-2250592)
 * Noticed I had misspelled blog_id as blogid. Problem solved.

Viewing 1 replies (of 1 total)

The topic ‘Activate theme programmatically’ is closed to new replies.

## Tags

 * [multisite](https://wordpress.org/support/topic-tag/multisite/)
 * [programmatically](https://wordpress.org/support/topic-tag/programmatically/)

 * 1 reply
 * 1 participant
 * Last reply from: [marlun](https://wordpress.org/support/users/marlun/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/activate-theme-programmatically/#post-2250592)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
