Title: WP_View_Config_Data::set
Published: August 20, 2026

---

# WP_View_Config_Data::set( array $patch, int $version ): 󠀁[WP_View_Config_Data](https://developer.wordpress.org/reference/classes/wp_view_config_data/)󠁿

## In this article

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

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

Replaces whole top-level keys, leaving the rest of the configuration alone.

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

Like merge() and replace(), set() applies a patch of top-level keys and touches 
only the keys the patch names: a key the patch omits keeps whatever it had, and 
a `null` value drops the key it names (which resets it to its default). The difference
is depth — where merge() and replace() merge a named key’s value into the current
one key by key, set() swaps the whole value in wholesale, dropping whatever the 
key held before. A `null` nested within that value still drops the property it names,
so set() honours nulls at every depth just as merge() and replace() do.

Use it when a callback owns a key outright and wants to pin it to an exact shape,
without the inherited default leaking through a key-by-key merge.

A patch that declares an unsupported schema version is rejected and does not change
anything.

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

 `$patch`arrayrequired

The partial configuration whose named keys to replace.

`$version`intrequired

The schema version the patch was authored against.

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

 [WP_View_Config_Data](https://developer.wordpress.org/reference/classes/wp_view_config_data/)
The instance, for chaining.

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

    ```php
    public function set( array $patch, int $version ) {
    	return $this->apply( $patch, $version, __METHOD__, 'set' );
    }
    ```

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

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

| Uses | Description | 
| [WP_View_Config_Data::apply()](https://developer.wordpress.org/reference/classes/wp_view_config_data/apply/)`wp-includes/class-wp-view-config-data.php` |

Applies a patch to the configuration, top-level key by top-level key.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_view_config_data/set/?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_view_config_data%2Fset%2F)
before being able to contribute a note or feedback.