Title: Some get_theme_mod() calls return bool(false)
Last modified: August 31, 2016

---

# Some get_theme_mod() calls return bool(false)

 *  [revansreturn](https://wordpress.org/support/users/revansreturn/)
 * (@revansreturn)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/)
 * Hello and thanks for having me.
 * I am creating a custom theme- currently adding some settings and controls. The
   problem I have is that SOME settings return
 * `bool(false)`
 * when called when I am NOT inside the Customizer. Other settings call just fine
   when I am working in/out of the Customizer. Seems like a scope or permissions
   issue? But then why would other settings call just fine.
 * **Example of setting that works both inside/outside of Customizer:**
 *     ```
       //	action bar color
       	$wp_customize->add_setting( 'action-bar-color', array( 'default' => '#99b1ff', 'transport' => 'postMessage'));
       	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'action-bar-color-control', array(
       		'label' => __( 'Action Bar Background Color', 'myTheme' ),
       		'section' => 'header-section',
       		'settings' => 'action-bar-color',
       		'priority' => 26
       	) ) );
       ```
   
 * **Example of setting that DOES NOT work outside of the Customizer:**
 *     ```
       // woocommerce header menu 'log in button' title
       	$wp_customize->add_setting( 'woo-menu-log-in-title', array( 'default' => 'Log In', 'transport' => 'refresh' ));
       	$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'woo-menu-log-in-control', array(
       		'label' => __( 'Log In Button Title', 'myTheme' ),
       		'section' => 'woocommerce-section',
       		'settings' => 'woo-menu-log-in-title',
       		'priority' => 14
       	) ) );
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [revansreturn](https://wordpress.org/support/users/revansreturn/)
 * (@revansreturn)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/#post-6924928)
 *     ```
       <?php
        echo var_dump(get_theme_mod('action-bar-color' )) . '<br />';
        echo var_dump(get_theme_mod( 'woo-menu-log-in-title' ));
       ?>
       ```
   
 * **Returns the following when OUTSIDE the Customizer:**
 *     ```
       string(7) "#99b1ff"
       bool(false)
       ```
   
 * **Returns the Following when INSIDE the Customizer:**
 *     ```
       string(7) "#99b1ff"
       string(6) "Log In"
       ```
   
 *  [codeManiac](https://wordpress.org/support/users/codemaniac/)
 * (@codemaniac)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/#post-6924941)
 * Hey revansreturn !
 * Its normal that it returns bool(false). If you check [get_theme_mod()](https://codex.wordpress.org/Function_Reference/get_theme_mod)
   in the codex, the 2nd parameter which is the variable $default is set to be false
   by default unless you give it a value 🙂
 * I hope this helped !
 * Cheers !
 *  Thread Starter [revansreturn](https://wordpress.org/support/users/revansreturn/)
 * (@revansreturn)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/#post-6924955)
 * Hey,
 * I don’t give defaults to any of the get_theme_mods that work. The manual says:
 * > IF the modification name does not exist, then the $default will be passed through
 * But all of my modification names DO exist, so get_theme_mod should return one
   of the following:
 * 1) their default setting value specified in add_setting()
    2) their setting as
   defined in the Customizer
 *  Thread Starter [revansreturn](https://wordpress.org/support/users/revansreturn/)
 * (@revansreturn)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/#post-6924982)
 * I’d like to provide an update.
 * At the beginning I set default values for every setting (like you should), and
   those values populated each setting the customizer section. Interestingly, I 
   decided to overwrite those values in the customizer and put new values in for
   each setting (I added ‘YEAH’ to the end of each one). Now they are accessible
   outside of the customizer environment AND when I’m logged out.
 * NO IDEA why that worked, nor do I know if this is a permanent fix, but thought
   I would pass the info on.
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Some get_theme_mod() calls return bool(false)’ is closed to new replies.

## Tags

 * [controls](https://wordpress.org/support/topic-tag/controls/)
 * [settings](https://wordpress.org/support/topic-tag/settings/)

 * 4 replies
 * 2 participants
 * Last reply from: [revansreturn](https://wordpress.org/support/users/revansreturn/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/some-get_theme_mod-calls-return-boolfalse/#post-6924982)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
