Title: WP_Customize_Manager::start_previewing_theme
Published: April 25, 2014
Last modified: April 28, 2025

---

# WP_Customize_Manager::start_previewing_theme()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#wp--skip-link--target)

If the theme to be previewed isn’t the active theme, add filter callbacks to swap
it out at runtime.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#source)󠁿

    ```php
    public function start_previewing_theme() {
    	// Bail if we're already previewing.
    	if ( $this->is_preview() ) {
    		return;
    	}

    	$this->previewing = true;

    	if ( ! $this->is_theme_active() ) {
    		add_filter( 'template', array( $this, 'get_template' ) );
    		add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
    		add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );

    		// @link: https://core.trac.wordpress.org/ticket/20027
    		add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
    		add_filter( 'pre_option_template', array( $this, 'get_template' ) );

    		// Handle custom theme roots.
    		add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
    		add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
    	}

    	/**
    	 * Fires once the Customizer theme preview has started.
    	 *
    	 * @since 3.4.0
    	 *
    	 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
    	 */
    	do_action( 'start_previewing_theme', $this );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-manager.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-customize-manager.php#L679)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-customize-manager.php#L679-L709)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#hooks)󠁿

 [do_action( ‘start_previewing_theme’, WP_Customize_Manager $manager )](https://developer.wordpress.org/reference/hooks/start_previewing_theme/)

Fires once the Customizer theme preview has started.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Customize_Manager::is_preview()](https://developer.wordpress.org/reference/classes/wp_customize_manager/is_preview/)`wp-includes/class-wp-customize-manager.php` |

Determines whether it is a theme preview or not.

  | 
| [WP_Customize_Manager::is_theme_active()](https://developer.wordpress.org/reference/classes/wp_customize_manager/is_theme_active/)`wp-includes/class-wp-customize-manager.php` |

Checks if the current theme is active.

  | 
| [add_filter()](https://developer.wordpress.org/reference/functions/add_filter/)`wp-includes/plugin.php` |

Adds a callback function to a filter hook.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#)

| Used by | Description | 
| [WP_Customize_Manager::save_changeset_post()](https://developer.wordpress.org/reference/classes/wp_customize_manager/save_changeset_post/)`wp-includes/class-wp-customize-manager.php` |

Saves the post for the loaded changeset.

  | 
| [WP_Customize_Manager::setup_theme()](https://developer.wordpress.org/reference/classes/wp_customize_manager/setup_theme/)`wp-includes/class-wp-customize-manager.php` |

Starts preview and customize theme.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/start_previewing_theme/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_manager%2Fstart_previewing_theme%2F)
before being able to contribute a note or feedback.