WP Customizer – Prevent live preview

Visit this link and read about transporter argument: https://codex.wordpress.org/Theme_Customization_API

Is that what you are looking for?

Here is an example for you:

<?php

add_action( 'customize_register', 'my_customizer' );
function my_customizer($wp_customize){
    $wp_customize->add_section( 'my_section', 
        array(
            'title' => __( 'My Custom Section', 'mytheme' ), //Visible title of section
            'capability' => 'edit_theme_options', //Capability needed to tweak
        )
    );
    $wp_customize->add_setting( 'my_setting', 
        array(
            'default' => 'option1', //Default setting/value to save
            'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
            'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting.
            'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
        ) 
    );
    $wp_customize->add_control(
        'my_control', 
        array(
            'label'    => __( 'My Custom Control', 'mytheme' ),
            'section'  => 'my_section',
            'settings' => 'my_setting',
            'type'     => 'radio',
            'choices'  => array(
                'option1'  => 'Option 1',
                'option2' => 'Option 2',
            ),
        )
    );
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)