What is the method to switch to specific page on entering theme customizer screen?

Question

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 '
    <script>
    wp.customize.previewer.previewUrl.set(wp.customize.settings.url + "?page_id=45");
    </script>
    ';
  }
}

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.

0
Nadal 3 weeks 2021-09-04T18:49:38-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse