有没有办法从无线阵列中删除其中一个选项?例如,我试图从选项数组中删除“bottom”:
$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\',
),
)
);
我知道下面的类可以修改控件中几乎所有的值,但选项数组除外:
$wp_customize->get_control(\'your_control_id\')->description = __( \'New Description\' );
你知道怎么做吗?
最合适的回答,由SO网友:David Lee 整理而成
您可以指定new array
在那里,有更新的选项:
$wp_customize->get_control( \'your_control_id\' )->choices = array( \'top\' => \'top\', \'bottom\' => \'bottom\' );
在我的
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 );