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

---

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

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

Removes named properties from the configuration, leaving the rest alone.

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

Where merge(), replace(), and set() take a patch of _values_ to write, remove() 
takes a spec of _names_ to delete, and its shape mirrors the configuration it prunes:

 * A list of names deletes each named entry from the value at that level: a key 
   from an associative array, or the member with a matching identity (`id`, `slug`,`
   field`, or a bare scalar) from a list.
 * An associative array maps a name to a nested spec, recursing into that entry’s
   value to delete from within it.

Naming a top-level configuration key is the one exception: like a `null` value in
a patch, it resets that key to its default rather than dropping it outright, so 
top-level removal and top-level `null` compose the same way.

So `array( 'default_view' )` resets the whole `default_view` key to its default,`
array( 'default_view' => array( 'sort' ) )` drops just its `sort` property, and `
array( 'default_view' => array( 'fields' => array( 'f2' ) ) )` drops the `f2` member
from its `fields` list. A name that is not present is ignored, and a list is renumbered
after a member is removed.

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

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

 `$spec`arrayrequired

The names to remove, keyed to match the configuration shape.

`$version`intrequired

The schema version the spec was authored against.

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

    ```php
    public function remove( array $spec, int $version ) {
    	if ( $version <= 0 || $version > self::LATEST_VERSION ) {
    		_doing_it_wrong(
    			__METHOD__,
    			esc_html__( 'A view configuration patch must declare a supported schema version.' ),
    			'7.1.0'
    		);

    		return $this;
    	}

    	// A flat list names top-level keys to reset; a map recurses into each
    	// named key to prune from within its value.
    	$spec_is_list = array_is_list( $spec );
    	foreach ( $spec as $spec_key => $spec_value ) {
    		$key = $spec_is_list ? $spec_value : $spec_key;

    		if ( ! in_array( $key, self::CONFIG_KEYS, true ) ) {
    			_doing_it_wrong(
    				__METHOD__,
    				sprintf(
    					/* translators: %s: the configuration key. */
    					esc_html__( '"%s" is not a documented view configuration key.' ),
    					esc_html( $key )
    				),
    				'7.1.0'
    			);
    			continue;
    		}

    		if ( $spec_is_list ) {
    			// Removing a top-level key resets it to its default, just as a
    			// null patch value does.
    			$this->config[ $key ] = $this->defaults[ $key ] ?? array();
    		} elseif ( array_key_exists( $key, $this->config ) ) {
    			$this->config[ $key ] = $this->remove_properties( $this->config[ $key ], $spec_value );
    		}
    	}

    	return $this;
    }
    ```

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

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

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

Removes the properties a spec names from the current value.

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

Retrieves the translation of $text and escapes it for safe use in HTML output.

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

Escaping for HTML blocks.

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

Marks something as being incorrectly called.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_view_config_data/remove/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_view_config_data/remove/?output_format=md#)

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