从documentation:
要添加、删除或修改任何自定义程序对象,并访问自定义程序管理器,请使用customize_register 挂钩:
function themeslug_customize_register( $wp_customize ) {
// Do stuff with $wp_customize, the WP_Customize_Manager object.
}
add_action( \'customize_register\', \'themeslug_customize_register\' );
Customizer Manager为每个Customizer对象类型提供add\\u、get\\u和remove\\u3种方法;每个都使用一个id。get\\uMethods允许在添加控件时直接修改指定的参数。
add_action(\'customize_register\',\'my_customize_register\');
function my_customize_register( $wp_customize ) {
$wp_customize->add_panel();
$wp_customize->get_panel();
$wp_customize->remove_panel();
$wp_customize->add_section();
$wp_customize->get_section();
$wp_customize->remove_section();
$wp_customize->add_setting();
$wp_customize->get_setting();
$wp_customize->remove_setting();
$wp_customize->add_control();
$wp_customize->get_control();
$wp_customize->remove_control();
}
因此,在您的情况下,可以使用
WP_Customize_Manager::remove_control()
.
十九世纪主题示例:
function my_theme_customize_register( $wp_customize ) {
// Remove the Colors -> Primary Color option.
$wp_customize->remove_control( \'primary_color\' );
}
add_action( \'customize_register\', \'my_theme_customize_register\', 11 );