remove_query_arg

Removes an item or items from a query string.

Description

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

Returns (string)

New URL query string.

Parameters (2)

0. $key (string|array)
Query key or keys to remove.
1. $query — Optional. (bool) => false
When false uses the $_SERVER value.

Usage

  1. if ( !function_exists( 'remove_query_arg' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.core.php'; 
  3.  
  4. // Query key or keys to remove. 
  5. $key = null; 
  6.  
  7. // When false uses the $_SERVER value. 
  8. $query = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = remove_query_arg($key, $query); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/backpress/functions.core.php  
  1. function remove_query_arg( $key, $query=false ) { 
  2. if ( is_array( $key ) ) { // removing multiple keys 
  3. foreach ( $key as $k ) 
  4. $query = add_query_arg( $k, false, $query ); 
  5. return $query; 
  6. return add_query_arg( $key, false, $query );