• Resolved David Vongries

    (@davidvongries)


    Hey guys!

    I was taking a look at the docs here (https://aristath.github.io/kirki/docs/arguments/partial_refresh.html) and trying to figure out how to use partial refresh for a background/text or any other color field.

    The default customizer way would look something like this:

    $wp_customize->selective_refresh->add_partial('hero_background_color', array(
      'selector' => '#hero-css',
      'settings' => 'hero_background_color',
      'render_callback' => function() {
        return self::css('.hero', 'background-color', 'hero_background_color');
      },
    ) );
Viewing 1 replies (of 1 total)
  • Hey there!

    If you want to use partial refresh on that field, the code for its partial_refresh argument would look like this:

    'partial_refresh' => array(
    	'hero_background_color' => array(
    		'selector'        => '#hero-css',
    		'render_callback' => function() {
    			return self::css( '.hero', 'background-color', 'hero_background_color' );
    		},
    	),
    ),

    Don’t forget that you’ll have to set transport to postMessage or auto for that field too!

    If that doesn’t work for some reason, please test if the development version on https://github.com/aristath/kirki works for you.
    If you’re still having issues with that, you can open a ticket in github ??

    Though for color fields I would advise you to take a look at the output argument too. If you use the output argument and set transport to auto it should auto-calculate all JS needed to make it work in the customizer, and your CSS will be added on the frontent

Viewing 1 replies (of 1 total)
  • The topic ‘Partial Refresh for background-color’ is closed to new replies.