• Hello,

    This is part of a custom theme option i use through customize

    $wp_customize->add_setting( 'theme_ppr_options[rating]', //No need to use a SERIALIZED name, astheme_mod` settings already live under one db record
    array(
    ‘default’ => $ppr_options[‘rating’], //Default setting/value to save
    ‘type’ => ‘option’, //Is this an ‘option’ or a ‘theme_mod’?
    ‘capability’ => ‘edit_theme_options’, //Optional. Special permissions for accessing this setting.
    ‘transport’ => ‘postMessage’, //What triggers a refresh of the setting? ‘refresh’ or ‘postMessage’ (instant)?
    )
    ); `

    But the selected value is not saved. The default values are always saved.

    I also made a theme options panel under appearance>Theme options and here everthing works. Just editing theme options by customize.php doesn’t work.

Viewing 1 replies (of 1 total)
  • Thread Starter DDT

    (@ddt)

    i think i see the cause this. I have this on top of the customization file

    function ppr_get_default_options() {
        $options = array(
            'logo' => '',
            'rating'=> '3'
        );
        return $options;
    }
    
    function ppr_options_init() {
        $ppr_options = get_option( 'theme_ppr_options' );
    
        // Are our options saved in the DB?
        if ( false === $ppr_options ) {
            // If not, we'll save our default options
            $ppr_options = ppr_get_default_options();
            add_option( 'theme_ppr_options', $ppr_options );
        }
    
        // In other case we don't need to update the DB
    }
    
    // Initialize Theme options
    add_action( 'after_setup_theme', 'ppr_options_init' );

    edit1 i tried

    if ( false === $ppr_options ) {
            // If not, we'll save our default options
            $ppr_options = ppr_get_default_options();
            add_option( 'theme_ppr_options', $ppr_options );
        } else {
            update_option('theme_ppr_options', $ppr_options);
        }

Viewing 1 replies (of 1 total)
  • The topic ‘Custom theme option are not saved with customize.php?’ is closed to new replies.