0

I am trying to employ the theme customizer and I am seeing an issue. For some reason, the text that is stored in the customizer will not show in the footer but when I click on the customizer, it does show on the preview. I have found that if I delete the text and remake it, it usually works. I should not have to do that though. Do you see an issue in my code?

 add_action('customize_register', 'add_footer_copyright');

 function add_footer_copyright($wp_customize) {

  $wp_customize->add_setting( 'footer_copyright', array(
 'default' => 'Copyright &copy; 201 - Designed By: <a href="http://example.com"  title="Designed & Developed By">Designer Name</a>',
  'capability' => 'edit_theme_options',

  ) );

 $wp_customize->add_control( 'footer_copyright', array(
 'label' => 'Footer Copyright',
 'section' => 'title_tagline',
 'type' => 'text'
 ) );
}
2

I have rewrote the code you given with minor changes. Please try this:



add_action('customize_register', 'add_footer_copyright');

 function add_footer_copyright($wp_customize) {

  $wp_customize->add_setting( 'footer_copyright', array(
  'default' => 'Copyright © 201 - Designed By: Designer Name',
  'transport' => 'postMessage',
  'capability' => 'edit_theme_options',

  ) );

 $wp_customize->add_control( 'footer_copyright', array(
 'label' => 'Footer Copyright',
 'section' => 'title_tagline',
 'settings'   => 'footer_copyright',
 'type' => 'text'
 ) );
}

You will notice that I added transport in add_setting and settings in add_control. Please note that the transport can be either 'refresh' (default) or 'postMessage'. Only set this to 'postMessage' if you are writing custom Javascript to control the Theme Customizer's live preview.

I checked by removing transport since I do not have Javascript to control the Theme Customizer's live preview. The settings are getting saved in first shot and reflecting when I reload the page.

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.