0

Is there a way to remove one of the choices from radio array? For example, I'm trying to remove 'bottom' from the choices' array:

    $wp_customize->add_control(
    'your_control_id', 
    array(
        'label'    => __( 'Control Label', 'mytheme' ),
        'section'  => 'your_section_id',
        'description' => 'your_description,
        'settings' => 'your_setting_id',
        'type'     => 'radio',
        'choices'  => array(
            'top'  => 'top',
            'bottom'  => 'bottom',
            'left'  => 'left',
            'right' => 'right',
        ),
    )
);

I know that the class below can modify nearly all the values from the control except the choices' array:

$wp_customize->get_control('your_control_id')->description = __( 'New Description' );

Any idea how to do this?

1

You can assign a new array there, with the updated options:

$wp_customize->get_control( 'your_control_id' )->choices = array( 'top' => 'top', 'bottom' => 'bottom' );

enter image description here

used this in my functions.php

function modify_choice( $wp_customize ){
    $wp_customize->get_control( 'your_control_id' )->choices = array( 'top' => 'top', 'bottom' => 'bottom' );
}

add_action( 'customize_register' , 'modify_choice',999 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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