• I have successfully made some new theme modifications using the Theme Customization API, but have run into a problem that doesn’t seem to be documented. In the last step, where I am setting up the writing of the CSS to in the head, the get_theme_mod function isn’t picking up the default value I defined when I setup the setting with add_setting.

    The documentation for get_theme_mod says that there is a second argument, which is either boolean or a string. Obviously, I can spell out the default value I want here, but this makes this statement very long (I’m specifying a url for a background image), and ignores the fact that I already defined the default during the add_setting process.

    I have tried making the second argument to get_theme_mod TRUE (the numeral 1 is passed to the CSS), ‘true’ (the word true is passed), 1 (the numeral 1 is passed), with no luck getting it to pass my default value from the add_setting method. (When I tried using default with no quotes I got an error since default is a reserved keyword in PHP relating to switch functions.)

    What can I pass to get_theme_mod to instruct it to pick up the default value for that setting that I included as an argument to the add_setting method?
    Thanks in advance for all help!

  • The topic ‘get_theme_mod doesn't get default set in add_setting function’ is closed to new replies.