WordPress at Your Fingertips

remove_query_arg() WP 1.0

Removes an item or items from a query string.

1 time — 0.000055 sec (very fast) | 50000 times — 0.19 sec (very fast) | PHP 7.1.5, WP 4.8.2

No Hooks.

Return

String. New URL query string.

Usage

remove_query_arg( $key, $query );
$key(string|string[]) (required)
Query key or keys to remove.
$query(false|string)
When false uses the current URL.
Default: false

Changelog

Since 1.5.0 Introduced.

Code of remove_query_arg() WP 5.8.1

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 );
}

Main Query

No comments
    Log In