2
votes

Here is my code in functions.php :-

<?php

add_theme_support('menus');

register_nav_menus(

array('primary' =>__('Primary Menu'))

);


function awesome_script_enque(){



 wp_enqueue_style('customstyle',get_template_directory_uri().'css/awesome.css',array(),'1.0.0','all');




wp_enqueue_script('customjs',get_template_directory_uri().'css/awesome.js',array(),'1.0.0',true);

}

add_action('wp_enqueue_scripts','awesome_script_enque');

function awesome_customizer_register($wp_customize){

$wp_customize->add_section('awesome_colors',array(
'title' => __('Colors','awesome'),
'description'=>'Modify the theme colour' )
);
$wp_customize->add_setting('background_color',array(
'default' => '#fff',
));

$wp_customize->add_control( new 
WP_Customize_Color_Control($wp_customize,'background_color',array(
'label' =>__('Edit Background Color','awesome') ,
'selection' =>'awesome_colors',
'settings'=>'background_color'
 )));

 }
 add_action('customize_register','awesome_customizer_register');

 function customtheme_customize_css()
 {
 ?>
 <style type="text/css">
 h1{color:<<?php echo get_theme_mod('background_color','#fff'); ?>}
</style>
<?php
}
?>

I referred lots of tutorial all of them had same process. Still I am not able to get customizer box named Colors in customize area where there are options like menus ,static front page etc..... Can any one point out what I am doing wrong ?

1

1 Answers

2
votes

Here is the small mistake on your code. On the last line, you have change font color, not background and also you are not adding function via a hook. Below is the correct code:

function customtheme_customize_css()
{
 ?>
 <style type="text/css">
 h1{background:<?php echo get_theme_mod('background_color','#fff'); ?>}
 </style>
<?php
}
add_action( 'wp_head', 'wpdocs_style' );