If I want to use select option with different choices in my WordPress theme customizer, how can I make that choice to change on live on the theme.
So, I have a section in my functions.php file like this:
$wp_customize->add_setting(
'menu_type',
array(
'transport' => 'postMessage',
'default' => 'choice1',
)
);
$wp_customize->add_control(
'menu_type',
array(
'type' => 'select',
'label' => 'Select your menu type:',
'section' => 'header_section',
'choices' => array(
'choice1' => 'Choice 1',
'choice2' => 'Choice 2',
'choice3' => 'Choice 3',
'choice4' => 'Choice 4',
),
)
);
And in my ajax file I have a section like this:
wp.customize( 'menu_type', function( value ) {
value.bind( function( newval ) {
$('.someclass').css('border', '1px solid #111');
} );
} );
Code in the ajax file changes css to ALL the choices. So what do I need to add in my ajax file, so I can make change for “choice1” ONLY instead?
Ok, heres the answer: