Title: WP_Theme_JSON::get_feature_selector
Published: August 20, 2026

---

# WP_Theme_JSON::get_feature_selector( $feature_selectors, string $feature_key, string $default_selector ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#changelog)

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Returns the appropriate selector for a block support feature’s preset CSS variables.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_theme_json/get_feature_selector/?output_format=md#description)󠁿

If the block defines a feature-level selector (as a string or an object with a `
root` key), that selector is returned. Otherwise, the block’s default selector is
used.

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

`string|array`<string, string>> $feature_selectors The block’s feature selectors
map.

`$feature_key`stringrequired

The feature to look up (e.g. `'dimensions'`).

`$default_selector`stringrequired

Fallback selector.

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

 string The resolved selector.

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

    ```php
    private static function get_feature_selector( array $feature_selectors, string $feature_key, string $default_selector ): string {
    	if ( ! isset( $feature_selectors[ $feature_key ] ) ) {
    		return $default_selector;
    	}

    	$feature = $feature_selectors[ $feature_key ];

    	if ( is_string( $feature ) ) {
    		return $feature;
    	}

    	if ( isset( $feature['root'] ) && is_string( $feature['root'] ) ) {
    		return $feature['root'];
    	}

    	return $default_selector;
    }
    ```

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

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

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.0/) | Introduced. |

## User Contributed Notes

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