Skip to content

Instantly share code, notes, and snippets.

@MarcGuay
Created September 4, 2015 13:00
Show Gist options
  • Save MarcGuay/5c1bd8ab2a17027297f4 to your computer and use it in GitHub Desktop.
Save MarcGuay/5c1bd8ab2a17027297f4 to your computer and use it in GitHub Desktop.
get_theme_mods() vs get_theme_mod()
// wp-content/themes/twentyfifteen/inc.customizer.php
$wp_customize->add_setting( 'test-color', array(
'default' => '#f72525',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'test-color', array(
'label' => __( 'Test Color', 'twentyfifteen' ),
'section' => 'colors',
) ) );
// wp-content/themes/twentyfifteen/header.php
$theme_mods = get_theme_mods();
echo "<pre>";
var_dump($theme_mods);
echo "test-color: ". get_theme_mod('test-color');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment