The "sortable" control

Learn how to create controls using Kirki

Back to Controls

Returnsarray

The documentation site is currently being rewritten. If you can't find what you're looking for please check the github issues and ask for assistance there until the documentation rewrite is complete.

Example:

Kirki::add_field( 'theme_config_id', array(
	'type'        => 'sortable',
	'settings'    => 'my_setting',
	'label'       => __( 'This is the label', 'textdomain' ),
	'section'     => 'section_id',
	'default'     => array(
		'option3',
		'option1',
		'option4'
	),
	'choices'     => array(
		'option1' => esc_attr__( 'Option 1', 'textdomain' ),
		'option2' => esc_attr__( 'Option 2', 'textdomain' ),
		'option3' => esc_attr__( 'Option 3', 'textdomain' ),
		'option4' => esc_attr__( 'Option 4', 'textdomain' ),
		'option5' => esc_attr__( 'Option 5', 'textdomain' ),
		'option6' => esc_attr__( 'Option 6', 'textdomain' ),
	),
	'priority'    => 10,
) );

Example of how to load template parts based on the value of the control in a template:

<?php
// Get the parts.
$template_parts = get_theme_mod( 'my_setting', array( 'option3', 'option1', 'option4' ) );

// Loop parts.
foreach ( $template_parts as $template_part ) {
	get_template_part( 'partial-templates/' . $template_part );
}
Edit this page