Hi, I'm trying to use active_callback to show/hide options depending on setting. I've tried lots of variations, but without any luck.
3.0.25
theme_mods
// Featured Slider Show control
Kirki::add_field( 'deo_config', array(
'type' => 'switch',
'settings' => 'deo_featured_slider_show_settings',
'label' => esc_html__( 'Show Featured Slider', 'meridia' ),
'section' => 'deo_featured_slider',
'default' => 1,
'priority' => 10,
'choices' => array(
'on' => esc_attr__( 'On', 'meridia' ),
'off' => esc_attr__( 'Off', 'meridia' ),
),
) );
// Featured Slider Posts control
Kirki::add_field( 'deo_config', array(
'type' => 'number',
'settings' => 'deo_featured_slider_posts_settings',
'label' => esc_html__( 'How many posts to show', 'meridia' ),
'section' => 'deo_featured_slider',
'default' => 3,
'priority' => 10,
'active_callback' => array(
'setting' => 'deo_featured_slider_show_settings',
'value' => 'on',
'operator' => '==',
),
'choices' => array(
'min' => 0,
'max' => 10,
'step' => 1,
),
) );
Please read https://aristath.github.io/kirki/docs/controls/switch.html
They return a boolean
The do not return on/off strings. The on/off - as stated in the docs is only used for the labels.
Furthermore, the active_callback is an array of arrays. 韦ry something like this:
'active_callback' => array(
array(
'setting' => 'deo_featured_slider_show_settings',
'value' => true,
'operator' => '==',
),
),
Great, nested array did the trick, thanks.
Most helpful comment
Great, nested array did the trick, thanks.