Is it possible that i can make a live view on PHP Variable with Theme Customization API? Thanks!
from header.php
<div id="number"><?php echo get_theme_mod( 'numberInput' ); ?></div>
above is working fine on live preview but below code is not appearing on live
<?php
$mynumber = get_theme_mod( 'numberInput' );
$cars=array("Nothing","Volvo","BMW","Toyota");
echo $cars[$mynumber];
?>
from function.php (add control)
$wp_customize->add_control(
'numberInput',
array(
'section' => 'number_options',
'label' => 'Number',
'type' => 'select',
'choices' => array(
'1' => 'One',
'2' => 'Two',
'3' => 'Three'
)
)
);
from theme-customizer.js
(function( $ ) {
wp.customize( 'numberInput', function( value ) {
value.bind( function( to ) {
$( '#number' ).text( to );
});
});
})( jQuery );
directly link for the screenshot of code Screenshot