3

To activate the Customizer core section Navigation (ID: nav), you need to:

add_theme_support( 'custom-header' );

I already tried to make the transport of the Customizer header_image setting postMessage with the ID based on what I'm seeing at get_header_image():

function theme_customize_register( $wp_customize ) {
    $wp_customize->get_setting( 'header_image' )->transport = 'postMessage';

    // I also tried this line.
    // $wp_customize->get_setting( 'header_image', get_theme_support( 'custom-header', 'default-image' ) )->transport = 'postMessage';
}
add_action( 'customize_register', 'theme_customize_register' );

But the setting transport is still refresh. And because the code above didn't work, it looks like the ID of the Customizer Header Image setting is not header_image.. What is the Header Image's ID and how to make it postMessage?

1 Answer 1

3

Luckily, I was facing the same issue an hour ago so I brainstormed for a long time to find a find a solution. I posted it here before seeing this: http://www.hardeepasrani.com/2015/12/using-postmessage-transport-method-for-header-image/

So instead of just using:

$wp_customize->get_setting( 'header_image' )->transport = 'postMessage';

I used:

$wp_customize->get_setting( 'header_image'  )->transport = 'postMessage';
$wp_customize->get_setting( 'header_image_data'  )->transport = 'postMessage';

After that, in JS, we got the value using header_image.

Hope it helps you. :)

3
  • Good to hear you found a solution, but please extend your link-only answer. The link could change in the future, thus making the answer not useful to others. Thanks.
    – birgire
    Dec 26, 2015 at 22:07
  • 2
    @birgire Done. :) Dec 27, 2015 at 1:44
  • Thanks for sharing! I am glad I found this before jumping into the source.
    – prtksxna
    Mar 22, 2019 at 4:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.