WordPress at a glance

remove_query_arg() WP 1.0

Removes an item or items from a query string.

Works based on: add_query_arg()
✈ 1 time = 0.000055s = very fast | 50000 times = 0.19s = 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/array) (required)
Query key or keys to remove.
$query(true/false/string)
When false uses the current URL.
Default: false

Code of remove_query_arg: wp-includes/functions.php VER 5.0.1

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

Related Functions

From category: Main Query

No comments
    Hello, !     Log In . Register