Launch Offer – Kirki PRO is now available! 🚀Get it while it lasts!

Multicheck

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 as seen in the example below.

Example

new \Kirki\Field\Multicheck(
	[
		'settings' => 'multicheck_setting',
		'label'    => esc_html__( 'My Control', 'kirki' ),
		'section'  => 'section_id',
		'default'  => [ '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.

Last updated on: January 21st, 2022

Scroll to Top

Download

Subscribe & be the first to be informed about
new features & updates!