A WordPress-centric search engine for devs and theme authors



remove_query_arg ›

Since1.5.0
Deprecatedn/a
remove_query_arg ( $key, $query = false )
Parameters: (2)
  • (string|array) $key Query key or keys to remove.
    Required: Yes
  • (bool|string) $query Optional. When false uses the current URL. Default false.
    Required: No
    Default: false
Returns:
  • (string) New URL query string.
Defined at:
Codex:

Removes an item or items from a query string.



Source

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