I'm having an issue where the Customizer Preview doesn't seem to fully refresh, but if I manually refresh the page the changes work. I've made a simplified example of the issue I'm experiencing:

I have a simple checkbox in the Customizer:

            'default'     => false,

    new WP_Customize_Control(
            'label'      => 'Checkbox',
            'section'    => 'test_section',
            'settings'   => 'test_checkbox',
            'type'       => 'checkbox',

In my functions.php file I have an if statement that checks if the checkbox is checked and if it is, I create a function:

if(get_theme_mod('test_checkbox', false) == true) {
    function test_function() {
        return 'SUCCESS';

In my index.php file I check if the function exists and echo it

if(function_exists('test_function')) {
    echo test_function();

Now when I go to the Customizer and check the checkbox, the Preview refreshes but I don't see the Success message. I have to manually refresh the page before I see it.

Does anyone know why this happens?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.