Launch Offer – Kirki PRO is now available! 🚀Get it while it lasts!

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:

<?php
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() { ?>
			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 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.

Last updated on: February 7th, 2022

Scroll to Top

Download

Subscribe & be the first to be informed about
new features & updates!