
On Multicheck fields, you can specify the options that will be available to your users by editing the choices
argument and specifying an array of options in the form of key => label
.
Please keep in mind that you should always use WordPress’s i18n functions for your labels and descriptions so they are translatable. More information on WordPress’s i18n functions can be found on the WordPress Codex.
Example
Kirki::add_field( 'theme_config_id', [
'type' => 'multicheck',
'settings' => 'multicheck_setting',
'label' => esc_html__( 'My Control', 'kirki' ),
'section' => 'section_id',
'default' => array('option-1', 'option-3', 'option-4'),
'priority' => 10,
'choices' => [
'option-1' => esc_html__( 'Option 1', 'kirki' ),
'option-2' => esc_html__( 'Option 2', 'kirki' ),
'option-3' => esc_html__( 'Option 3', 'kirki' ),
'option-4' => esc_html__( 'Option 4', 'kirki' ),
'option-5' => esc_html__( 'Option 5', 'kirki' ),
],
] );
Usage
<?php $multicheck_value = get_theme_mod( 'multicheck_setting', array( 'option-1', 'option-3' ) ); ?>
<?php if ( ! empty( $multicheck_value ) ) : ?>
<ul>
<?php foreach ( $multicheck_value as $checked_value ) : ?>
<li><?php echo $checked_value; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Please keep in mind that the returned values are the keys of the settings you have defined, not their labels. If you want to display the labels then you will have to implement this on your code.