I created a custom header option in the customizer and am having a few problems i just cant work out. All the codes are working, ive checked multiple tutorials as well as the wp codex and cant seem to work it out. The page, fields and preview are all working, when i click save and publish it shows the working icon and then finishes with no errors. When i try refresh the page or go back however, the browser tells me navigating away will not save any changes, if i do that and refresh, the changes are not saved. Secondly while the default color i selected shows in the preview with all other changes, on the frontend the changes do not show (maybe because its not saving, so need to resolve that first). Below is my functions code.
PROBLEM SOLVED: Allocated Memory Ran Out. Increased it in the HTACCESS file.
// =========================================================================== //
// ADD HEADER IMAGE AND COLOR TO CUSTOMIZER
// =========================================================================== //
function customizer_header( $wp_customize ) {
// ADD SECTIONS
$wp_customize->add_section( 'header_section', array(
'title' => __( 'Navigation Bar', 'dc_header' ),
'priority' => 80,
) );
// ADD SETTINGS
$wp_customize->add_setting(
'header_color',
array(
'default' => '#09c',
'sanitize_callback' => '',
)
);
$wp_customize->add_setting(
'header_image',
array(
'default' => '',
'sanitize_callback' => '',
)
);
// ADD CONTROLS
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'header_color_control',
array(
'label' => __( 'Header Color', 'dc_header_color' ),
'section' => 'header_section',
'settings' => 'header_color',
)
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'header_image',
array(
'label' => __( 'Header Image', 'dc_header_image' ),
'section' => 'header_section',
'settings' => 'header_image',
)
)
);
}
add_action( 'customize_register', 'customizer_header' );
// ADD TO FRONTEND
function dc_header_css() {
?>
<style type="text/css">
header { background: <?php echo get_theme_mod( 'header_color' ); ?>; }
</style>
<?php
}
add_action( 'wp_head', 'dc_header_css' );