1. Alex Mansfield
    Alex Mansfield
    at /

    Congratulations on your first blog post! I’m looking forward to updating my tutorial with your contribution when I get a change.

  2. Richard LaFranchi
    Richard LaFranchi
    at /

    Thanks! I’ve been looking all over for a solution to this. I was sure there was a simple solution, and I’m glad I’ve found it. I’ve got about a dozen options that use a select field, so this makes it much easier.

  3. Alex Vasquez
    Alex Vasquez
    at /

    Hey there,
    Thanks for a great write up. I’m still confused.

    I’m not sure how to use this function. Below is my code. Just trying to figure out how to get this done. I’m not sure where to place the function or what I might need to change.

    // Mobile Nav Hide Right Arrow
    function digistarter_sanitize_choices( $input, $setting ) {
    global $wp_customize;

    $control = $wp_customize->get_control( $setting->id );

    if ( array_key_exists( $input, $control->choices ) ) {
    return $input;
    } else {
    return $setting->default;
    }
    }

    $wp_customize->add_setting(
    ‘digistarter_mobile_hide_arrow’,
    array(
    ‘default’ => “No”
    )
    );
    $wp_customize->add_control(
    ‘digistarter_mobile_hide_arrow’,
    array(
    ‘section’ => ‘nav’,
    ‘label’ => ‘Mobile Navigation Hide Right Arrow’,
    ‘type’ => ‘radio’,
    ‘choices’ => array(“Yes”, “No”),
    )
    );

  4. Tung Do
    Tung Do
    at /

    Awesome, I’m glad I came across this after reading Alex’s tutorial. Thanks for sharing!

  5. Sarah
    Sarah
    at /

    I know you wrote this forever ago but I just wanted to say THANK YOU! I’ve literally spent the last 3 hours pulling my hair out, with everyone saying the same damned thing and none of it working the way I wanted. I KNEW there had to be a way to not have to write in the same data twice. This should definitely be a core WP function. It’s so simple! (Once you know it)

  6. Matt
    Matt
    at /

    Thank you so much! I’ve read a lot of articles from reputable sources and I haven’t been able to find this. It’s even better than anything I’d hoped to find. This will save me a lot of time and frustration!

  7. geo
    geo
    at /

    Hi,
    First thank a lot for this. I have an issue which said:

    Warning: array_key_exists() expects parameter 2 to be array, null given in

    It’s like the $setting var doesn’t exist.

    Is someone already faced this issue?

Comments are closed, but trackbacks and pingbacks are open.