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

---

# WP_View_Config_Data::replace( 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/replace/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?output_format=md#changelog)

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

Replaces list values while merging the rest of a partial configuration.

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

Takes the same arguments as merge() and applies the patch the same way, with one
difference: a list in the patch replaces the current list wholesale instead of merging
into it by member identity. Associative arrays still merge key by key, `null` still
drops what it names, and a scalar still replaces the current value.

It shouldn’t be the default choice — a callback that replaces a list stops inheriting
core’s future additions to it — but it’s useful when a contributor needs to pin 
a list to an exact set of members.

The shape rule applies here too: a patch value whose shape does not match the current
value — an associative array where a list lives, or a non-empty list where an associative
value lives — is rejected with a notice and leaves the current value unchanged. 
An empty array is exempt, so replacing a list with an empty list still clears it.

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/replace/?output_format=md#parameters)󠁿

 `$patch`arrayrequired

The partial configuration to apply.

`$version`intrequired

The schema version the patch was authored against.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_view_config_data/replace/?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/replace/?output_format=md#source)󠁿

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

[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#L331)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-view-config-data.php#L331-L333)

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