Title: switch theme
Last modified: February 3, 2020

---

# switch theme

 *  Resolved [spok72](https://wordpress.org/support/users/spok72/)
 * (@spok72)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/switch-theme/)
 * This plugin is a great solution.
    What code to use to switch between two templates?
    -  This topic was modified 6 years, 2 months ago by [spok72](https://wordpress.org/support/users/spok72/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/switch-theme/#post-12393507)
 * You can use the `stylesheet` filter to change the active child theme:
 *     ```
       add_filter( 'stylesheet', function ( $theme ) {
       	return 'twentytwelve';
       } );
       ```
   
 * If you would like to change the active parent theme, you need to use the `template`
   filter as well:
 *     ```
       $theme_callback = function ( $theme ) {
       	return 'twentytwelve';
       };
   
       add_filter( 'stylesheet', $theme_callback );
       add_filter( 'template', $theme_callback );
       ```
   
 *  Thread Starter [spok72](https://wordpress.org/support/users/spok72/)
 * (@spok72)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/switch-theme/#post-12393648)
 * thank you very much for your quick reply. I will hook this code and check if 
   it works.
 * Regards
 *  Thread Starter [spok72](https://wordpress.org/support/users/spok72/)
 * (@spok72)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/switch-theme/#post-12405432)
 * Works but only temporarily. When I click on any link, after passing back the 
   old template.
    The change is not permanent within the page being viewed
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/switch-theme/#post-12409449)
 * Hi [@spok72](https://wordpress.org/support/users/spok72/),
 * If you’d like a more permanent change, then you can use the [`switch_theme`](https://codex.wordpress.org/Function_Reference/switch_theme)
   function.
 * Keep in mind that this function has a permanent effect, so you don’t need to 
   run it on every page load. You could use it in an only run once snippet, or have
   some sort of check for when you want to use it.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘switch theme’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

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

 * 4 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/switch-theme/#post-12409449)
 * Status: resolved