Register Control Types

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

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

add_action( 'customize_register', function( $wp_customize ) {
	 * The custom control class
	class Kirki_Controls_Notice_Control extends Kirki\Control\Base {
		public $type = 'notice';
		public function render_content() { ?>

	// 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 by defining notice as your field’s type.

By extending Kirki_Control_Base instead of WordPress’ core WP_Customize_Control you give your custom control access to all Kirki’s arguments such as output.

Was this helpful?