Title: WP_Customize_Control::get_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Customize_Control::get_link( string $setting_key = ‘default’ ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#wp--skip-link--target)

Gets the data link attribute for a setting.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#parameters)󠁿

 `$setting_key`stringoptional

Default:`'default'`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#return)󠁿

 string Data link parameter, a `data-customize-setting-link` attribute if the `$
setting_key` refers to a pre-registered setting, and a `data-customize-setting-key-
link` attribute if the setting is not yet registered.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#source)󠁿

    ```php
    public function get_link( $setting_key = 'default' ) {
    	if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) {
    		return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
    	} else {
    		return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"';
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-control.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-customize-control.php#L450)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-customize-control.php#L450-L456)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#related)󠁿

| Uses | Description | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  |

| Used by | Description | 
| [WP_Customize_Control::link()](https://developer.wordpress.org/reference/classes/wp_customize_control/link/)`wp-includes/class-wp-customize-control.php` |

Renders the data link attribute for the control’s input element.

  | 
| [WP_Customize_Control::render_content()](https://developer.wordpress.org/reference/classes/wp_customize_control/render_content/)`wp-includes/class-wp-customize-control.php` |

Renders the control’s content.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_control/get_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key. | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_control%2Fget_link%2F)
before being able to contribute a note or feedback.