Panels & Sections

Initializing Kirki Panels and Sections

To add custom panels and sections using Kirki, place your code inside a function hooked to after_setup_theme. Here’s the recommended structure:

add_action( 'after_setup_theme', 'initialize_kirki_settings', 20 );

function initialize_kirki_settings() {
	if ( ! class_exists( 'Kirki' ) ) {
		return;
	}

	// Add your Kirki panels and sections here
}

Note: You can rename the function (initialize_kirki_settings) to anything you like, as long as it’s meaningful within your codebase.

Adding Panels

Panels are wrappers for sections – a way to group multiple sections together. To see how to create Panels using the WordPress Customizer API please take a look at these docs.

Adding Panels in Kirki:

new \Kirki\Panel(
	'panel_id',
	[
		'priority'    => 10,
		'title'       => esc_html__( 'My Panel', 'kirki' ),
		'description' => esc_html__( 'My Panel Description.', 'kirki' ),
	]
);

Adding Sections

Sections are wrappers for controls – a way to group multiple controls together. All fields must belong to a section. To see how to create Sections using the WordPress Customizer API please take a look at these docs.

Adding Sections in Kirki:

new \Kirki\Section(
	'section_id',
	[
		'title'       => esc_html__( 'My Section', 'kirki' ),
		'description' => esc_html__( 'My Section Description.', 'kirki' ),
		'panel'       => 'panel_id',
		'priority'    => 160,
	]
);

Was this helpful?