Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need help figuring out how the radio button saves it's value in the theme settings.

In my theme I added Radio buttons in the theme customizer. So far they are working great. Although I have one issue. I can't seem to set a default setting for them, so if I install my theme on a new install, or someone else does. Than whatever the radio buttons are for doesn't appear. I am not talking about the default value of the radio button itself, I am talking about the default theme customizers settings value. Here is how I create the radio buttons:

        /** Header button options */

    $wp_customize->add_setting(
    'header_btn_options',
    array(
        'default' => 'duplicatebtn',
    ) );

$wp_customize->add_control(
    'header_btn_options',
    array(
        'type' => 'radio',
        'priority'   => 30,
        'label' => 'Header buttons type',
        'section' => 'mytheme_header',
        'choices' => array(
        'duplicatebtn' => 'Use hero settings',
        'createcustom' => 'Use custom settings(modify below)',
        'hidebtn' => 'Do not display button',
         ),
    )
);  

Here is how I set my theme setting defaults. I do this so that when a new install is done the theme looks okay.

function mytheme_get_theme_mods() {
    $defaults = array(
        'mytheme_header_btn_options'     => 'duplicatebtn'
);

    return $defaults;

So this is my confusion. Even though I tried setting my default to a choice from the array, it does not work. Although when I save a new value from the radio buttons on the theme customizer it works like that. So it clearly has some value just not "duplicatebtn", or maybe it is and I am doing it wrong. Can anyone please help me figure this out?

share|improve this question
    
I also had similar problem on one of my theme for setting defaults. I will keep watching this Q. –  Sisir Nov 16 '13 at 8:13
    
Yea, it is a little confusing. I thought was the way it saves the setting, but that can't be true since the switch that changes the content of each radio case works fine in my theme customizer live preview. –  user1632018 Nov 16 '13 at 18:13
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.