I'm using Kirki and trying to generate a toggle for each term in custom taxonomy (to add ability to show/hide posts for each term in the theme later):

function generate_toggles() {
$months = get_terms( array('months') );
    foreach ($months as $month) :
        Kirki::add_field( 'mytheme', array(
            'type'        => 'toggle',
            'settings'    => $month->slug,
            'label'       => __( 'Июль', 'my_textdomain' ),
            'section'     => 'months',
            'default'     => '1',
            'priority'    => 10,
add_action('???', 'generate_toggles', 9999);

What I don't understand though is where do I attach the action? Since I want it in Kirki panel – which action should I attach it to?

  • You don't need an action. Or a wrapping function... you can just write your foreach directly.
    – Aristeides
    Commented Jun 21, 2017 at 4:15

1 Answer 1


You can use a Kirki helper class for this (pass your taxonomy into Kirki_Helper::get_terms), but you need to register after the taxonomies are registered, otherwise you get an error:

function my_theme_add_categories_customizer_control() {
Kirki::add_field('my_config', array(
    'type' => 'multicheck',
    'settings' => 'show_months',
    'label' => esc_attr__('My Control', 'my_textdomain'),
    'section' => 'months',
    'priority' => 10,
    'choices' => Kirki_Helper::get_terms(array('months'))

add_action( 'init', 'my_theme_add_categories_customizer_control', 12 );

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.