I'm customizing my Customization options in a WordPress theme following a video from awfulmedia (http://www.youtube.com/watch?v=XloM1F5M2fU). It's very good, but I've got one hang up.
function martinStart_footer_customizer_register($wp_customize) {
$wp_customize->add_section('footer_styles', array(
'title' => __('Footer Styles', 'martinStart'),
'description' => 'Modify Footer Styles'
));
$wp_customize->add_setting('footer_background', array(
'default' => '#CCC',
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'footer_background_ctrl', array(
'label' => __('Footer Background Color', 'martinStart'),
'section' => 'footer_styles',
'settings' => 'footer_background'
) ));
}
function martinStart_footer_style() {
?>
<style type="text/css">
.site-footer {background-color: <$php echo get_theme_mod('footer_background'); ?>;}
</style>
<?php
}
add_action('wp_head', 'martinStart_footer_style');
add_action('customize_register', 'martinStart_footer_customizer_register');
So I use the Wordpress custom_color_control and the color change is saved in the wp_options table, and style declaration is added to the head.
But the value isn't added, it writes the php code! Can anyone see what I'm doing wrong?
php code most be surrounded by <?php code ?>
, but the code in question begins with <$php
. You need to replace the $ with a ?.