I'm having some trouble using the Theme Customization API for the first time. I'm following a tutorial, but I seem to be doing something wrong. I'm trying to allow users to change text on a page through the WordPress Theme Customization options.

I've added all the hooks to my functions.php file and a separate .js file called theme-customizer.js.

My current setup looks like this:



function tcx_register_theme_customizer( $wp_customize ) {

      'title'     => 'Display Options',
      'priority'  => 200

      'default'            => 'All Rights Reserved',
      'sanitize_callback'  => 'tcx_sanitize_copyright',
      'transport'          => 'postMessage'

      'section'  => 'tcx_display_options',
      'label'    => 'Copyright Message',
      'type'     => 'text'

add_action( 'customize_register', 'tcx_register_theme_customizer' );

function tcx_sanitize_copyright( $input ) {
  return strip_tags( stripslashes( $input ) );

function tcx_customizer_live_preview() {
    get_template_directory_uri() . '/library/js/theme-customizer.js',
    array( 'jquery', 'customize-preview' ),

add_action( 'customize_preview_init', 'tcx_customizer_live_preview' );


(function( $ ) {
  "use strict";

  wp.customize( 'tcx_footer_copyright_text', function( value ) {
    value.bind( function( to ) {
      $( '.hero-content header h2' ).text( to );

})( jQuery );


<div class="hero-content">
    <h2><?php echo get_theme_mod( 'tcx_footer_copyright_message' ); ?></h2>

When I go to customise the theme, firstly I can't see the 'default' text. When I type in the input field, the typed text appears on the page. When I hit Save however, and refresh the page, the changes don't appear to have been saved. And the text area is blank.

Any idea of what I'm doing wrong. Any help is appreciated. Thanks in advance!

1 Answer 1


Well, first problem:



echo get_theme_mod( 'tcx_footer_copyright_message' );

Those aren't the same setting names.

Note sure why you don't see the default value in the input field, as there's nothing wrong there. Although you should also define the same default in the second parameter of the get_theme_mod() call.

  • Ahh, thanks for pointing out the obvious. That seems to have done the trick! In regards to the second parameter you mention, would that be something like echo get_theme_mod( 'tcx_footer_copyright_message', default ); ??
    – realph
    Commented Jan 15, 2015 at 23:30
  • That would be something like echo get_theme_mod('tcx_footer_copyright_message', 'All Rights Reserved');
    – Otto
    Commented Jan 16, 2015 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.