0

I'm trying to modify the WordPress theme customizer by adding sections and settings but no matter what I add in my functions.php file, nothing ever shows up in the customizer.

Here is my code:-

function starter_customize_register( $wp_customize ) 
{
    $wp_customize->add_panel( 'home_page_settings', array(
        'title' => __( 'Home Page Settings', 'starter'),
        'priority' => 10,
        'active_callback' => 'is_front_page'
    ) );

    $wp_customize->add_section( 'home_call_to_action_section' , array(
        'title' => __('Call To Action','starter'),
        'panel' => 'home_page_settings',
    ) );

    $wp_customize->add_setting( 'home_call_to_action_setting_section', array(
        'default'        => __('WHAT IS RO PURIFIER?', 'starter'),
        'sanitize_callback' => 'starter_sanitize',
    ));
    $wp_customize->add_control('cta_heading', array(
        'label' => __('CTA Heading','starter'),
        'section' => 'home_call_to_action_section',
        'setting'=>'home_call_to_action_setting_section'

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

Thanks in advance..

| improve this question | | | | |
1

Your use of add_control is incorrect. More specifically, you are not telling what type of control you want to add. Refer to the codex link to see which types can be generated automatically. I've given an example with a text field below.

$wp_customize->add_control('cta_heading', array(
    'label' => __('CTA Heading','starter'),
    'section' => 'home_call_to_action_section',
    'setting'=>'home_call_to_action_setting_section',
    'type'=>'text',
));  

Beware that if you want more complex controls, such as colours, you need to explicitly create the control object. An example is given in the codex link as well.

| improve this answer | | | | |
  • I have added type but still no luck.. – Vipin May 31 '17 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.