0

Here is the code I'm using to add the section to the Customize panel.

function apple_customize_register($wp_customize){
$wp_customize->add_section('apple_footer', array(
    'title'    => 'Footer',
    'priority' => 120,
));
//------ display copyright in footer
$wp_customize->add_setting('theme_options[copyright]', array(
    'capability' => 'edit_theme_options',
    'type'       => 'option',
));
$wp_customize->add_control('theme_options[copyright]', array(
    'settings' => 'theme_options[copyright]',
    'label'    => __('Display Copyright'),
    'section'  => 'apple_footer',
    'type'     => 'checkbox',
    'value' => '1'
));
}
add_action('customize_register', 'apple_customize_register');

How do I use the values in my theme. I have tryed get_option('theme_options[copyright]'), get_theme_mod('theme_options[copyright]') and many more, but all var_dump out bool(false). Please tell me what I'm missing.

1 Answer 1

0
$wp_customize->add_setting('theme_options[copyright]', array(
'default'    => '1',
'capability' => 'edit_theme_options',
'type'       => 'option',
));

There is nothing wrong except the default value (missing). You cant use your setting till you store it a value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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