On entering the theme customizer, it defaults to the set home page, however I need to change the default to a page with ID 45.

The set home page uses a special template and is formatted by the elementor plugin so it is not expected to respond to the theme customizations. The page ID 45 uses the primary theme and is not set for public display, but solely for the purpose of previewing the changes.

I tried the following without success

add_action('customize_register', function($mgr) 
  add_action('customize_controls_print_scripts', function() 
    echo '
    wp.customize.previewer.previewUrl.set(wp.customize.settings.url + "?page_id=45");

The console error states cannot read property of previewUrl but I am stumped on resolving the errors. I reviewed the customizer js api at https://developer.wordpress.org/themes/customize-api/the-customizer-javascript-api/ but just cannot determine the correct process.

1 Answer 1


I defined the solution using

add_action('customize_register', function($mgr) {

Source https://developer.wordpress.org/reference/classes/wp_customize_manager/set_preview_url/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.