WP_Customize_Manager::add_control( WP_Customize_Control|string $id, array $args = array() ): WP_Customize_Control

Adds a customize control.


Top ↑

See also

Top ↑


$id WP_Customize_Control|string Required
Customize Control object, or ID.
$args array Optional
Array of properties for the new Control object.
See WP_Customize_Control::__construct() for information on accepted arguments.
More Arguments from WP_Customize_Control::__construct( ... $args ) Array of properties for the new Control object.
  • instance_number int
    Order in which this instance was created in relation to other instances.
  • manager WP_Customize_Manager
    Customizer bootstrap instance.
  • id string
    Control ID.
  • settings array
    All settings tied to the control. If undefined, $id will be used.
  • setting string
    The primary setting for the control (if there is one).
    Default 'default'.
  • capability string
    Capability required to use this control. Normally this is empty and the capability is derived from $settings.
  • priority int
    Order priority to load the control. Default 10.
  • section string
    Section the control belongs to.
  • label string
    Label for the control.
  • description string
    Description for the control.
  • choices array
    List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values.
  • input_attrs array
    List of custom input attributes for control output, where attribute names are the keys and values are the values. Not used for 'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types.
  • allow_addition bool
    Show UI for adding new content, currently only used for the dropdown-pages control. Default false.
  • json array
    Deprecated. Use WP_Customize_Control::json() instead.
  • type string
    Control type. Core controls include 'text', 'checkbox', 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional input types such as 'email', 'url', 'number', 'hidden', and 'date' are supported implicitly. Default 'text'.
  • active_callback callable
    Active callback.

Default: array()

Top ↑


WP_Customize_Control The instance of the control that was added.

Top ↑


File: wp-includes/class-wp-customize-manager.php. View all references

public function add_control( $id, $args = array() ) {
	if ( $id instanceof WP_Customize_Control ) {
		$control = $id;
	} else {
		$control = new WP_Customize_Control( $this, $id, $args );

	$this->controls[ $control->id ] = $control;
	return $control;

Top ↑


Version Description
4.5.0 Return added WP_Customize_Control instance.
3.4.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Marcio Zebedeu

    basic use

    function register_customize_sections( $wp_customize ) {
        $wp_customize->add_section( 'example', array(
           'title'=> __( 'Add Your Name', 'TextDomain' ),
           'priority' => 201
        ) );
        $wp_customize->add_setting( 'setting' );
        $wp_customize->add_control( 'setting', array(
            'id'=> 'id',
            'label' => __( 'First Name:', 'TextDomain' ),
            'section' => 'example'
        ) );

You must log in before being able to contribute a note or feedback.