customizer-scripts.js

index.php
<h1>Copyright : <?php echo get_theme_mod('copyright_text'); ?></h1>

functions.php
function customize_api($custom_val){
$custom_val->add_section('general_section',array(
'title' => 'General Options',
'priority' => 20
));

//For Copyright Text
$custom_val->add_setting('copyright_text',array(
'default' => 'Copyright Text',
'transport' => 'postMessage'
));
$custom_val->add_control('copyright_text',array(
'section' => 'general_section',
'label' => 'Copyright Text',
'type' => 'text'
));
}

add_action('customize_register','customize_api');

function scripts_for_customizer(){
wp_enqueue_script('customizer-scripts',get_template_directory_uri().'/js/customizer-scripts.js',array('jquery','customize-preview'));
}

add_action('customize_preview_init','scripts_for_customizer');

customizer-scripts.js
(function($){
$(document).ready(function(){
wp.customize('copyright_text',function(value){
value.bind(function(){
$('h1').hide();
});
});
})
})(jQuery)


Comments

Popular posts from this blog

Deploy laravel application to digital ocean droplet

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine