Removing pre existing menu item

I want to remove the following items from the customizer menu: However, I already tried a few codes from other Stack questions but with no luck! Is it even possible to remove those? 1 Answer 1 Here you go: $wp_customize->remove_section(‘colors’); $wp_customize->remove_section(‘nav_menus’); $wp_customize->remove_section(‘static_front_page’); EDIT AFTER DISCUSSION After testing I found that this doesn’t work for nav_menus. … Read more

Get/Set wp.customize.previewer.previewUrl

I am trying to get/set the current previewURL within the Customizer. I enqueue the script with the customize_controls_print_styles action: function my_custom_script() { wp_enqueue_script( ‘my-custom-script’, plugin_dir_url( __FILE__ ) . ‘/js/my-custom-script.js’ ); } add_action(‘customize_controls_print_styles’, ‘my_custom_script’); In the script I try to set the previewURL and refresh the previewer when the user clicks on a specific customizer section … Read more

How i can get widgets areas working in customizer?

I’m encountering a strange issue with WordPress. I’m building a theme and the theme customization is driven by Customizer. So, basically in functions.php I’m adding add_theme_support( ‘widget-customizer’ ); i’m registering a sidebar with: register_sidebar( array( ‘name’ => __( ‘Test Sidebar’ ), ‘id’ => ‘test-sidebar’, )); then in index.php i’m adding the common get_footer(); and in … Read more

JavaScript in WordPress Customizer

Customizer Codes: $wp_customize->add_setting ( ‘script-code’, array ( ‘default’ => esc_html__( ‘Script Code’, ‘x’ ), ‘sanitize_callback’ => ‘wp_kses_post’ ) ); $wp_customize->add_control ( new WP_Customize_Control ( $wp_customize, ‘script-code’, array ( ‘label’ => esc_html__( ‘Script Code’, ‘x’ ), ‘section’ => ‘script’, ‘settings’ => ‘script-code’, ‘type’ => ‘textarea’, ‘priority’ => 1 ) ) ); Photo from Customizer: from codes … Read more

WordPress Customizer sanitize_callback: How to Reset to Default on Fail

I check the sanity of some settings with sanitize_callback. It works, but on fail, I want to reset the value do the default one. How can I do that? $wp_customize->add_setting( $attribute[0], array( “default” => $attribute[1], “sanitize_callback” => $validate_func, ) ); EDIT An example for $validate_func is kb_validate_url_facebook which checks if the setting is an URL … Read more

WP Customizer JS Template not saving color field

I’m trying to create a custom typography control, I’m having problem saving the value of the color, please take a look at my code: <?php class Customizer_Typo_Control_Typography extends WP_Customize_Control { /** * The type of customize control being rendered. */ public $type=”typography”; /** * Array */ public $l10n = array(); /** * Set up our … Read more

New customizer setting not showing value

Edit: It’s working now, please lock the thread. I am using the Understrap framework (Underscores plus Bootstrap). $wp_customize->add_section( ‘understrap_theme_post_options’, array( ‘title’ => __( ‘Theme Post & Archive Settings’, ‘understrap’ ), ‘capability’ => ‘edit_theme_options’, ‘description’ => __( ‘Post and Archive Settings’, ‘understrap’ ), ‘priority’ => 160, ) ); $wp_customize->add_setting( ‘understrap_show_updated_post’, array( ‘default’ => ‘no’, ‘type’ => … Read more