Are you a theme author? Checkout new Kirki Helpers for your themes, or start something new using our _s fork as a starting point!

Register new Control Type

Improve this page

Though you can create new control types for the WordPress Customizer using its API, you may want to register your control with Kirki as well so you can define fields using that control type directly.

To do that you can write something like the example below:

<?php
add_action( 'customize_register', function( $wp_customize ) {
	/**
	 * The custom control class
	 */
	class Kirki_Controls_Notice_Control extends WP_Customize_Control {
		public $type = 'notice';
		public function render_content() { ?>
			THE CONTROL CONTENT HERE
			<?php
		}
	}
	// Register our custom control with Kirki
	add_filter( 'kirki/control_types', function( $controls ) {
		$controls['notice'] = 'Kirki_Controls_Notice_Control';
		return $controls;
	} );

} );
?>

You can then create new fields using your own control simply be defining notice as your field’s type.

The following docs are for Kirki 2.2.0 and above.