W3cubDocs

/WordPress

remove_query_arg( string|array $key, bool|string $query = false )

Removes an item or items from a query string.

Parameters

$key

(string|array) (Required) Query key or keys to remove.

$query

(bool|string) (Optional) When false uses the current URL.

Default value: false

Return

(string) New URL query string.

Source

File: wp-includes/functions.php

function remove_query_arg( $key, $query = false ) {
	if ( is_array( $key ) ) { // Removing multiple keys.
		foreach ( $key as $k ) {
			$query = add_query_arg( $k, false, $query );
		}
		return $query;
	}
	return add_query_arg( $key, false, $query );
}

Changelog

Version Description
1.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/remove_query_arg