Wordpress Save an Option form Customizer

2019-07-29 08:21发布

So I got this Code working, so It displays the Settings in the Wordpress Customizer. What is missing now, is that it saves it somewhere. I can not figure out how to do that. I was hoping someone could answer me this.

And since I don't know how to save it, I am not sure how I will be able to get it. with get_option() I can get things from the Database.

As far as I know, I currently only have the barebone structure, which does not provide saving or anything for my options (in the array). I am trying to follow this fairly old guide: LINK

add_action( 'customize_register', 'color_scheme_customize' );
function color_scheme_customize($wp_customize) {
$wp_customize->add_section( 'calmarstudio_color_scheme', array(
    'title'          => __( 'Color Scheme', 'calmarstudio' ),
    'priority'       => 35,
) );

$wp_customize->add_setting( 'calmarstudio_theme_options[color_scheme]', array(
    'default'        => 'some-default-value',
    'type'           => 'option',
    'capability'     => 'edit_theme_options',
) );

$wp_customize->add_control( 'calmarstudio_color_scheme', array(
    'label'      => __( 'Color Scheme', 'calmarstudio' ),
    'section'    => 'calmarstudio_color_scheme',
    'settings'   => 'calmarstudio_theme_options[color_scheme]',
    'type'       => 'radio',
    'choices'    => array(
        'blue' => 'Blue (Standard)',
        'orange' => 'Gold',
        'red' => 'Bordeaux',
        ),
) );
}

0条回答
登录 后发表回答