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

---

# WP_Customize_Manager::stop_previewing_theme()

## In this article

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

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

Stops previewing the selected theme.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/stop_previewing_theme/?output_format=md#description)󠁿

Removes filters to change the active theme.

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

    ```php
    public function stop_previewing_theme() {
    	if ( ! $this->is_preview() ) {
    		return;
    	}

    	$this->previewing = false;

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

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

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

    	/**
    	 * Fires once the Customizer theme preview has stopped.
    	 *
    	 * @since 3.4.0
    	 *
    	 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
    	 */
    	do_action( 'stop_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#L718)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-customize-manager.php#L718-L747)

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

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

Fires once the Customizer theme preview has stopped.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/stop_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.

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

Removes a callback function from 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/stop_previewing_theme/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_manager/stop_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.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/stop_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%2Fstop_previewing_theme%2F)
before being able to contribute a note or feedback.