WordPress Customizer Sortable Control
Learn how to create a sortable control using the Kirki Customizer Framework.
Back to ControlsReturnsarray
Learn how to create a sortable control using the Kirki Customizer Framework.
Back to ControlsReturnsarray
Example:
Kirki::add_field( 'theme_config_id', [
'type' => 'sortable',
'settings' => 'my_setting',
'label' => esc_html__( 'This is the label', 'kirki' ),
'section' => 'section_id',
'default' => [
'option3',
'option1',
'option4'
],
'choices' => [
'option1' => esc_html__( 'Option 1', 'kirki' ),
'option2' => esc_html__( 'Option 2', 'kirki' ),
'option3' => esc_html__( 'Option 3', 'kirki' ),
'option4' => esc_html__( 'Option 4', 'kirki' ),
'option5' => esc_html__( 'Option 5', 'kirki' ),
'option6' => esc_html__( 'Option 6', 'kirki' ),
],
'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 );
}
Can't find what you're looking for? Check the github issues or edit this page to add what's missing.