The "radio" control

Learn how to create controls using Kirki

Back to Controls

Returnsstring

Can't find what you're looking for? Check the github issues or edit this page to add what's missing.

You can define the available options using the choices argument and formating them as an array key => label.

Example

Kirki::add_field( 'theme_config_id', [
	'type'        => 'radio',
	'settings'    => 'my_setting',
	'label'       => esc_html__( 'Radio Control', 'textdomain' ),
	'section'     => 'section_id',
	'default'     => 'red',
	'priority'    => 10,
	'choices'     => [
		'red'   => esc_html__( 'Red', 'textdomain' ),
		'green' => esc_html__( 'Green', 'textdomain' ),
		'blue'  => esc_html__( 'Blue', 'textdomain' ),
	],
] );

In case you need to add additional, extra-long descriptions to your radio options you can use a format like this:

Kirki::add_field( 'theme_config_id', [
	'type'        => 'radio',
	'settings'    => 'my_setting',
	'label'       => esc_html__( 'Radio Control', 'textdomain' ),
	'section'     => 'section_id',
	'default'     => 'red',
	'priority'    => 10,
	'choices'     => [
		'red'   => [
			esc_html__( 'Red', 'my_textdomain' ),
			esc_html__( 'These are some extra details about Red', 'textdomain' ),
		],
		'green' => [
			esc_html__( 'Green', 'kirki' ),
			esc_html__( 'These are some extra details about Green', 'textdomain' ),
		],
		'blue'  => [
			esc_html__( 'Blue', 'kirki' ),
			esc_html__( 'These are some extra details about Blue', 'textdomain' ),
		],
	],
] );
Edit this page