I have a customizer option in my theme that has two sections: a drop-down menu and a text area. The drop down menu has three options: Active,Suspended and cancelled. I'm trying to find a way to hide the text area only if 'Suspended' is selected.

I've looked online and found something with active_callback but I'm unfamiliar with that callback.

Code so far:

function twsa_customizer( $wp_customize ) {
// Show schedule
$wp_customize->add_setting( 'twsa_show_schedule' );
$wp_customize->add_control( 'twsa_show_schedule', array(
'type' => 'select',
'label' => 'Show status',
'section' => 'twsa_show',
'choices' => array(
    'active' => 'Active',
    'suspended' => 'Suspended',
    'cancelled' => 'Cancelled',
),) );
$wp_customize->add_control('twsa_show_suspend', array(
'description' => 'Reason for suspension',
'section' => 'twsa_show',
'type' => 'textarea',
'active_callback' => 'estore_is_cart',
add_action( 'customize_register', 'twsa_customizer', 20 );

1 Answer 1


In this example, estore_is_cart should return true only if 'suspended' === $wp_customize->get_setting( 'twsa_show_schedule' )->value(). Or in other words:

$wp_customize->add_control( 'twsa_show_suspend', array(
    'description' => 'Reason for suspension',
    'section' => 'twsa_show',
    'type' => 'textarea',
    'active_callback' => function() use ( $wp_customize ) {
        return 'suspended' === $wp_customize->get_setting( 'twsa_show_schedule' )->value();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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