WordPress at a glance

is_customize_preview() WP 4.0.0

Checks whether the site is being previewed in the WordPress Customizer (the visual theme settings page). Conditional tag.

Uses global variable $wp_customize, which contains an instance of the WP_Customize_Manager class.

✈ 1 time = 0.000014s = very fast | 50000 times = 0.01s = speed of light | PHP 7.1.0, WP 4.7

No Hooks.


true/false. True if the site is being previewed in the Customizer, false otherwise.




#1 Usage example

if( is_customize_preview() ){
	// this is Customizer page

#2 Php function for Customizer only

The function code will only be executed when we are on WordPress Customizer admin page.

function my_function(){
	// exit if this is not Customizer 
	if( ! is_customize_preview() )

	// function code...

Code of is customize preview: wp-includes/theme.php WP 5.2.1

function is_customize_preview() {
	global $wp_customize;

	return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();

Related Functions

From tag: Conditional tags (page type and request)

More from tag: Conditional tags (all)

More from category: Settings (customizer)

No comments
    Hello, !     Log In . Register