You should not be using jQuery toggle
. This is directly manipulating the visibility of DOM elements. Instead, you should be using the active
state for the control, section, or panel. You can hide a control via control.active.set(false)
. You can do the same for a panel
or section
. See some more examples in my post Dependently-Contextual Customizer Controls. See also my answer at https://wordpress.stackexchange.com/a/286294/8521
To do the same with a panel or section, you’d do:
wp.customize.panel( 'idOfPanel', function( panel ) {
panel.active.set( false ); // Hide it.
// ...
} );
wp.customize.section( 'idOfSection', function( section ) {
section.active.set( true ); // Show it.
// ...
} );
In the “…” you’d probably want to also override the validate
method on the active
state to force to have a certain value so that when the Customizer preview refreshes, the active_callback
doesn’t override what you set in JS.
Related Posts:
- How do I remove a pre-existing customizer setting?
- Theme customizer – settings order
- Custom Image section in Customizer
- Is it possible ( or advisable) to allow open access to the new theme customizer for potential clients?
- Add a dropdown to theme customizer
- Allow Shortcode in Theme Customizer
- Theme Customizer – Nested Sections?
- Can I create customizer setting that can handle plugin shortcode?
- Editing the custom background CSS
- Is the theme customizer slowing down my site?
- WordPress Customize — Move “menus” options / field to another section
- Changing the entire control choices using wp.customize with JavaScript
- How to remove menus section from WordPress theme customizer
- Checking if there is an Image inserted – if not don’t display anything
- “Display Site Title and Tagline” checkbox not working?
- Default header image does not display
- Responsive Images – Generating multiple images from Theme Customizer control upload?
- Modify the Additional CSS section (adding a disclaimer)
- wordpress custom theme import and export options for sample data [closed]
- How to hook CSS file according to theme selection in the customizer section
- Change setting name in Customizer and keep the data
- after_setup_theme, Global Variable and Theme Customizer
- Custom Script Section Only Echoes Text
- WordPress not registering Theme Customization Section
- WP Customize refresh problem
- Get a setting value conditionally in the Customizer api
- How to add new args data in $wp_customize->add_setting?
- WP_Customize_Color_Control omitting # symbol
- Hide header texts (Title & Tagline) in custom-header.php
- get_option in header.php not returning value from customizer
- Internal error 500 accessing Theme > Customize
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- Theme-wide custom post template
- Disabling Customizer Selective Refresh shortcut icons for selected controls
- JavaScript stops working on selectively refreshed sections one inside the other
- Folder name for a pro version of a WordPress.org theme?
- Display theme layouts [closed]
- Customizer: save setting/control content to post/page
- Using WordPress’ Theme Customizer to select page templates that update layout in the preview
- Dynamically generated wordpress customizer options?
- Is accessing theme and using customizer GPL distribution?
- How to disable wordpress from overload my stylesheet styles with customizer styles
- Override customizer values on a per-menu base
- How to enqueue javascript for WP Customize options sidebar?
- Theme Customizer not loading JS for live preview
- Change WordPress header color using customizer
- Default Text not showing from customizer
- Is there any way to register custom background images like header images?
- How to transfer one domain to another domain without losing theme options (customizer)?
- Theme Customizer not displaying saved values in wp_head (CSS)
- How to allow certain PHP functions when using sanitize_callback in the word press customizer
- Customizer Color Control Not Working
- where is real values of variables?
- How to allow users to create their own website within my domain? [closed]
- Doing context-aware previews in the WordPress Customizer
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- Alignment Problem [closed]
- Avada Child Theme Development
- Questions from a new WP Dev [closed]
- Theme customizer – can’t add section/settings
- Theme logo metadata into template file
- WP Customazation API doesn’t save the default Value
- Twenty Twelve Author not displaying
- Related Post Category Filter
- How to add wysiwyg editor in customize screen using customize_register
- How to register dynamic settings in WordPress Customizer?
- How to copy page/post from one theme to another?
- How to change listing type permlink?
- In wordpress customizer div still showing even if I hid it with javascript
- Removing element from DOM with jquery through plugin Custom Scripts for Customizer
- Why does wp_customizer default values do not apply when theme is installed for the first time?
- Customizer API Multi Sections in single Panel
- Default customizer colors aren’t displayed outside of the preview
- fetch all post from wp multisite network and sort all the post in descending order on the basis of “Created by ” term
- How Do I Create a WordPress Demo Site with Limited Admin Access
- Fatal error: Class WP_Customize_Image_Control not found
- What is difference between add_theme_support and Theme Customization API?
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- How do I remove header/page-title image in farvis theme? [closed]
- How to show Custom Field Value in Woocommerce Shop Page
- How to show some of category in wordpress
- Duplicate child theme incl. design changes
- Text View (Code View) in WordPress Customizer TinyMCE Editor
- Is there a way to create sections under “Colors” panel in the Theme Customizer?
- Import settings from another theme
- Nav menus Fast previewing not working with wp_get_nav_menu_items!
- Customizer Image-Picker Preview Not Working
- How to customize the colors within a stylesheet using a WordPress setting
- Correct was to customise theme using get_theme_mod in scripts
- How to get url image page the right way?
- How to create multiple customizer controls in one control
- Load get_page_templates into select menu
- WordPress Customizer Help with FontAwesome Icon
- WordPress Customization API overwrite LESS variable
- Customizer API way function is_customize_preview() works only in main page?
- “No Data Received” error in Chrome every time i try to update the theme functions file
- trying to figure out how to use more that one image upload in the same section in theme customizer
- How do I make it super customisable?
- How to make a multilingual wordpress site to be translated one-to-one without much effort and without using translate?
- My theme is full of error messages in the “Customize” screen, but nowhere else