On this page
remove_query_arg( string|string[] $key, false|string $query = false ): string
Removes an item or items from a query string.
Parameters
$keystring|string[] Required-
Query key or keys to remove.
$queryfalse|string Optional-
When false uses the current URL.
Default:
false
Return
string New URL query string.
Source
File: wp-includes/functions.php. View all references
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
Uses
| Uses | Description |
|---|---|
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
Used By
| Used By | Description |
|---|---|
| WP_Customize_Manager::set_return_url() wp-includes/class-wp-customize-manager.php | Sets URL to link the user to when closing the Customizer. |
| wp_admin_bar_customize_menu() wp-includes/admin-bar.php | Adds the “Customize” link to the Toolbar. |
| wp_admin_canonical_url() wp-admin/includes/misc.php | Removes single-use URL parameters and create canonical link based on new URL. |
| wp_media_attach_action() wp-admin/includes/media.php | Encapsulates the logic for Attach/Detach actions. |
| wp_prepare_themes_for_js() wp-admin/includes/theme.php | Prepares themes for JavaScript. |
| WP_List_Table::view_switcher() wp-admin/includes/class-wp-list-table.php | Displays a view switcher. |
| WP_List_Table::pagination() wp-admin/includes/class-wp-list-table.php | Displays the pagination. |
| WP_List_Table::print_column_headers() wp-admin/includes/class-wp-list-table.php | Prints column headers, accounting for hidden and sortable columns. |
| set_screen_options() wp-admin/includes/misc.php | Saves option for number of rows when listing posts, pages, comments, etc. |
| wp_dashboard_setup() wp-admin/includes/dashboard.php | Registers dashboard widgets. |
| WP_Comments_List_Table::get_views() wp-admin/includes/class-wp-comments-list-table.php | |
| Walker_Nav_Menu_Edit::start_el() wp-admin/includes/class-walker-nav-menu-edit.php | Start the element output. |
| wp_nav_menu_item_post_type_meta_box() wp-admin/includes/nav-menu.php | Displays a meta box for a post type menu item. |
| wp_nav_menu_item_taxonomy_meta_box() wp-admin/includes/nav-menu.php | Displays a meta box for a taxonomy menu item. |
| WP_Customize_Manager::customize_preview_settings() wp-includes/class-wp-customize-manager.php | Prints JavaScript settings for preview frame. |
| wp_nonce_ays() wp-includes/functions.php | Displays “Are You Sure” message to confirm the action being taken. |
| wp_referer_field() wp-includes/functions.php | Retrieves or displays referer hidden field for forms. |
| get_pagenum_link() wp-includes/link-template.php | Retrieves the link for a page number. |
| wp_video_shortcode() wp-includes/media.php | Builds the Video shortcode output. |
| _remove_qs_args_if_not_in_url() wp-includes/canonical.php | Removes arguments from a query string if they are not present in a URL DO NOT use this in plugin code. |
| redirect_canonical() wp-includes/canonical.php | Redirects incoming links to the proper URL based on the site url. |
| _post_format_link() wp-includes/post-formats.php | Filters the post format term link to remove the format prefix. |
| get_cancel_comment_reply_link() wp-includes/comment-template.php | Retrieves HTML content for cancel comment reply link. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/remove_query_arg