Function: register_setting

register_setting( string $option_group, string $option_name, array $args )

Register a setting and its data.

Shortcut: rs

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

Parameters

Name Type(s) Default Value Description
$option_group string

A settings group name. Should correspond to a whitelisted option key name. Default whitelisted option key names include "general," "discussion," and "reading," among others.

$option_name string

The name of an option to sanitize and save.

$args array array()

{ Data used to describe the setting when registered.

@type string   $type              The type of data associated with this setting.
                                  Valid values are 'string', 'boolean', 'integer', and 'number'.
@type string   $description       A description of the data attached to this setting.
@type callable $sanitize_callback A callback function that sanitizes the option's value.
@type bool     $show_in_rest      Whether data associated with this setting should be included in the REST API.
@type mixed    $default           Default value when calling `get_option()`.

}

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.