add_action customize_register not working

I’ve been working on this for a long time but can’t get it fixed. I’m simply trying to get the function below to work but it’s refusing to do that.

I have put it in functions.php of my theme.

function options( $wp_customize ) {
    $wp_customize->add_control(
        'copyright_textbox',
        array(
            'label' => 'Copyright text',
            'section' => 'example_section_one',
            'type' => 'text'
        )
    );
}
add_action( 'customize_register', 'options' );

About to give up but my last hope is SO. What is hating on my in this code and what do I need to do to fix it?

1 Answer
1

You always need to be sure that three things are defined (section, setting and control).

If you are adding a control to an already defined section, i.e. title_tagline, then you don’t need to re-register it, but always define the setting and the control.

//adding setting for copyright text
add_action('customize_register', 'theme_copyright_customizer');

function theme_copyright_customizer($wp_customize) {
    //adding section in wordpress customizer   
    $wp_customize->add_section('copyright_extras_section', array(
        'title'          => 'Copyright Text Section'
    ));

    //adding setting for copyright text
    $wp_customize->add_setting('text_setting', array(
        'default'        => 'Default Text For copyright Section',
    ));

    $wp_customize->add_control('text_setting', array(
        'label'   => 'Copyright text',
        'section' => 'copyright_extras_section',
        'type'    => 'text',
    ));
}

Hope it helps!

Leave a Comment