Title: WP_Theme_JSON::get_default_slugs
Published: February 3, 2022
Last modified: February 24, 2026

---

# WP_Theme_JSON::get_default_slugs( array $data, array $node_path ): array

## In this article

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

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

Returns the default slugs for all the presets in an associative array whose keys
are the preset paths and the leaves is the list of slugs.

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

For example:

    ```php
    array(
      'color' => array(
        'palette'   => array( 'slug-1', 'slug-2' ),
        'gradients' => array( 'slug-3', 'slug-4' ),
      ),
    )
    ```

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

 `$data`arrayrequired

A theme.json like structure.

`$node_path`arrayrequired

The path to inspect. It’s `'settings'` by default.

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

 array

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

    ```php
    protected static function get_default_slugs( $data, $node_path ) {
    	$slugs = array();

    	foreach ( static::PRESETS_METADATA as $metadata ) {
    		$path = $node_path;
    		foreach ( $metadata['path'] as $leaf ) {
    			$path[] = $leaf;
    		}
    		$path[] = 'default';

    		$preset = _wp_array_get( $data, $path, null );
    		if ( ! isset( $preset ) ) {
    			continue;
    		}

    		$slugs_for_preset = array();
    		foreach ( $preset as $item ) {
    			if ( isset( $item['slug'] ) ) {
    				$slugs_for_preset[] = $item['slug'];
    			}
    		}

    		_wp_array_set( $slugs, $metadata['path'], $slugs_for_preset );
    	}

    	return $slugs;
    }
    ```

[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/6.9.4/src/wp-includes/class-wp-theme-json.php#L3428)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme-json.php#L3428-L3454)

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

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

Sets an array in depth based on a path of keys.

  | 
| [_wp_array_get()](https://developer.wordpress.org/reference/functions/_wp_array_get/)`wp-includes/functions.php` |

Accesses an array in depth based on a path of keys.

  |

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

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.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_default_slugs%2F)
before being able to contribute a note or feedback.