Title: add_query_arg
Published: April 25, 2014
Last modified: February 24, 2026

---

# add_query_arg( $args ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#wp--skip-link--target)

Retrieves a modified URL query string.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#description)󠁿

You can rebuild the URL and append query variables to the URL query by using this
function.
There are two ways to use this function; either a single key and value,
or an associative array.

Using a single key and value:

    ```php
    add_query_arg( 'key', 'value', 'http://example.com' );
    ```

Using an associative array:

    ```php
    add_query_arg( array(
        'key1' => 'value1',
        'key2' => 'value2',
    ), 'http://example.com' );
    ```

Omitting the URL from either use results in the current URL being used (the value
of `$_SERVER['REQUEST_URI']`).

Values are expected to be encoded appropriately with urlencode() or rawurlencode().

Setting any query variable’s value to boolean false removes the key (see [remove_query_arg()](https://developer.wordpress.org/reference/functions/remove_query_arg/)).

Important: The return value of [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)
is not escaped by default. Output should be late-escaped with [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)
or similar to help prevent vulnerability to cross-site scripting (XSS) attacks.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#parameters)󠁿

 `$key`string|arrayrequired

Either a query variable key, or an associative array of query variables.

`$value`stringoptional

Either a query variable value, or a URL to act upon.

`$url`stringoptional

A URL to act upon.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#return)󠁿

 string New URL query string (unescaped).

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#more-information)󠁿

#### 󠀁[Usage](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#usage)󠁿

    ```php
    // Parameters as separate arguments
    add_query_arg( $param1, $param2, $old_query_or_uri );

    // Parameters as array of key => value pairs
    add_query_arg(
    array(
    'key1' => 'value1',
    'key2' => 'value2',
    ...
    ),
    $old_query_or_uri
    );
    ```

## 󠀁[Source](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#source)󠁿

    ```php
    function add_query_arg( ...$args ) {
    	if ( is_array( $args[0] ) ) {
    		if ( count( $args ) < 2 || false === $args[1] ) {
    			$uri = $_SERVER['REQUEST_URI'];
    		} else {
    			$uri = $args[1];
    		}
    	} else {
    		if ( count( $args ) < 3 || false === $args[2] ) {
    			$uri = $_SERVER['REQUEST_URI'];
    		} else {
    			$uri = $args[2];
    		}
    	}

    	$frag = strstr( $uri, '#' );
    	if ( $frag ) {
    		$uri = substr( $uri, 0, -strlen( $frag ) );
    	} else {
    		$frag = '';
    	}

    	if ( 0 === stripos( $uri, 'http://' ) ) {
    		$protocol = 'http://';
    		$uri      = substr( $uri, 7 );
    	} elseif ( 0 === stripos( $uri, 'https://' ) ) {
    		$protocol = 'https://';
    		$uri      = substr( $uri, 8 );
    	} else {
    		$protocol = '';
    	}

    	if ( str_contains( $uri, '?' ) ) {
    		list( $base, $query ) = explode( '?', $uri, 2 );
    		$base                .= '?';
    	} elseif ( $protocol || ! str_contains( $uri, '=' ) ) {
    		$base  = $uri . '?';
    		$query = '';
    	} else {
    		$base  = '';
    		$query = $uri;
    	}

    	wp_parse_str( $query, $qs );
    	$qs = urlencode_deep( $qs ); // This re-URL-encodes things that were already in the query string.
    	if ( is_array( $args[0] ) ) {
    		foreach ( $args[0] as $k => $v ) {
    			$qs[ $k ] = $v;
    		}
    	} else {
    		$qs[ $args[0] ] = $args[1];
    	}

    	foreach ( $qs as $k => $v ) {
    		if ( false === $v ) {
    			unset( $qs[ $k ] );
    		}
    	}

    	$ret = build_query( $qs );
    	$ret = trim( $ret, '?' );
    	$ret = preg_replace( '#=(&|$)#', '$1', $ret );
    	$ret = $protocol . $base . $ret . $frag;
    	$ret = rtrim( $ret, '?' );
    	$ret = str_replace( '?#', '#', $ret );
    	return $ret;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L1139)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L1139-L1205)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_parse_str()](https://developer.wordpress.org/reference/functions/wp_parse_str/)`wp-includes/formatting.php` |

Parses a string into variables to be stored in an array.

  | 
| [urlencode_deep()](https://developer.wordpress.org/reference/functions/urlencode_deep/)`wp-includes/formatting.php` |

Navigates through an array, object, or scalar, and encodes the values to be used in a URL.

  | 
| [build_query()](https://developer.wordpress.org/reference/functions/build_query/)`wp-includes/functions.php` |

Builds a URL query based on an associative or indexed array.

  |

| Used by | Description | 
| [WP_REST_Abilities_V1_Categories_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_categories_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-categories-controller.php` |

Retrieves all ability categories.

  | 
| [WP_REST_Abilities_V1_List_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_list_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php` |

Retrieves all abilities.

  | 
| [_wp_get_site_editor_redirection_url()](https://developer.wordpress.org/reference/functions/_wp_get_site_editor_redirection_url/)`wp-admin/site-editor.php` |

Maps old site editor urls to the new updated ones.

  | 
| [WP_Automatic_Updater::has_fatal_error()](https://developer.wordpress.org/reference/classes/wp_automatic_updater/has_fatal_error/)`wp-admin/includes/class-wp-automatic-updater.php` |

Performs a loopback request to check for potential fatal errors.

  | 
| [WP_Plugin_Dependencies::check_plugin_dependencies_during_ajax()](https://developer.wordpress.org/reference/classes/wp_plugin_dependencies/check_plugin_dependencies_during_ajax/)`wp-includes/class-wp-plugin-dependencies.php` |

Checks plugin dependencies after a plugin is installed via AJAX.

  | 
| [WP_Script_Modules::get_src()](https://developer.wordpress.org/reference/classes/wp_script_modules/get_src/)`wp-includes/class-wp-script-modules.php` |

Gets the versioned URL for a script module src.

  | 
| [WP_REST_Font_Collections_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_font_collections_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php` |

Gets the font collections available.

  | 
| [WP_Plugin_Install_List_Table::get_more_details_link()](https://developer.wordpress.org/reference/classes/wp_plugin_install_list_table/get_more_details_link/)`wp-admin/includes/class-wp-plugin-install-list-table.php` |

Creates a ‘More details’ link for the plugin.

  | 
| [wp_get_plugin_action_button()](https://developer.wordpress.org/reference/functions/wp_get_plugin_action_button/)`wp-admin/includes/plugin-install.php` |

Gets the markup for the plugin install action button.

  | 
| [WP_Plugins_List_Table::get_view_details_link()](https://developer.wordpress.org/reference/classes/wp_plugins_list_table/get_view_details_link/)`wp-admin/includes/class-wp-plugins-list-table.php` |

Returns a ‘View details’ link for the plugin.

  | 
| [WP_REST_Global_Styles_Revisions_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_global_styles_revisions_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php` |

Returns paginated revisions of the given global styles config custom post type.

  | 
| [wp_admin_bar_edit_site_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_site_menu/)`wp-includes/admin-bar.php` |

Adds the “Edit Site” link to the Toolbar.

  | 
| [WP_REST_Sidebars_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_sidebars_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php` |

Prepares links for the sidebar.

  | 
| [core_auto_updates_settings()](https://developer.wordpress.org/reference/functions/core_auto_updates_settings/)`wp-admin/update-core.php` |

Display WordPress auto-updates settings.

  | 
| [WP_REST_Block_Directory_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_block_directory_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php` |

Generates a list of links to include in the response for the plugin.

  | 
| [WP_REST_Block_Types_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_block_types_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php` |

Prepares links for the request.

  | 
| [Plugin_Installer_Skin::do_overwrite()](https://developer.wordpress.org/reference/classes/plugin_installer_skin/do_overwrite/)`wp-admin/includes/class-plugin-installer-skin.php` |

Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload.

  | 
| [Theme_Installer_Skin::do_overwrite()](https://developer.wordpress.org/reference/classes/theme_installer_skin/do_overwrite/)`wp-admin/includes/class-theme-installer-skin.php` |

Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload.

  | 
| [WP_MS_Themes_List_Table::column_autoupdates()](https://developer.wordpress.org/reference/classes/wp_ms_themes_list_table/column_autoupdates/)`wp-admin/includes/class-wp-ms-themes-list-table.php` |

Handles the auto-updates column output.

  | 
| [WP_Privacy_Data_Removal_Requests_List_Table::column_email()](https://developer.wordpress.org/reference/classes/wp_privacy_data_removal_requests_list_table/column_email/)`wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php` |

Outputs the Actions column.

  | 
| [WP_Privacy_Data_Removal_Requests_List_Table::column_next_steps()](https://developer.wordpress.org/reference/classes/wp_privacy_data_removal_requests_list_table/column_next_steps/)`wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php` |

Outputs the Next steps column.

  | 
| [WP_MS_Sites_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/get_views/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Gets links to filter sites by status.

  | 
| [WP_Privacy_Data_Export_Requests_List_Table::column_email()](https://developer.wordpress.org/reference/classes/wp_privacy_data_export_requests_list_table/column_email/)`wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php` |

Actions column.

  | 
| [WP_Privacy_Data_Export_Requests_List_Table::column_next_steps()](https://developer.wordpress.org/reference/classes/wp_privacy_data_export_requests_list_table/column_next_steps/)`wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php` |

Displays the next steps column.

  | 
| [WP_Recovery_Mode_Link_Service::handle_begin_link()](https://developer.wordpress.org/reference/classes/wp_recovery_mode_link_service/handle_begin_link/)`wp-includes/class-wp-recovery-mode-link-service.php` |

Enters recovery mode when the user hits wp-login.php with a valid recovery mode link.

  | 
| [WP_Recovery_Mode_Link_Service::get_recovery_mode_begin_url()](https://developer.wordpress.org/reference/classes/wp_recovery_mode_link_service/get_recovery_mode_begin_url/)`wp-includes/class-wp-recovery-mode-link-service.php` |

Gets a URL to begin recovery mode.

  | 
| [wp_admin_bar_recovery_mode_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_recovery_mode_menu/)`wp-includes/admin-bar.php` |

Adds a link to exit recovery mode when Recovery Mode is active.

  | 
| [resume_theme()](https://developer.wordpress.org/reference/functions/resume_theme/)`wp-admin/includes/theme.php` |

Tries to resume a single theme.

  | 
| [wp_recovery_mode_nag()](https://developer.wordpress.org/reference/functions/wp_recovery_mode_nag/)`wp-admin/includes/update.php` |

Displays a notice when the user is in recovery mode.

  | 
| [WP_Site_Health::get_test_rest_availability()](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_rest_availability/)`wp-admin/includes/class-wp-site-health.php` |

Tests if the REST API is accessible.

  | 
| [WP_Site_Health::get_test_https_status()](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_https_status/)`wp-admin/includes/class-wp-site-health.php` |

Tests if the site is serving content over HTTPS.

  | 
| [resume_plugin()](https://developer.wordpress.org/reference/functions/resume_plugin/)`wp-admin/includes/plugin.php` |

Tries to resume a single plugin.

  | 
| [wp_check_php_version()](https://developer.wordpress.org/reference/functions/wp_check_php_version/)`wp-admin/includes/misc.php` |

Checks if the user needs to update PHP.

  | 
| [WP_REST_Search_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_search_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php` |

Retrieves a collection of search results.

  | 
| [wp_get_script_polyfill()](https://developer.wordpress.org/reference/functions/wp_get_script_polyfill/)`wp-includes/script-loader.php` |

Returns contents of an inline script used in appending polyfill scripts for browsers which fail the provided tests. The provided array is a mapping from a condition to verify feature support to its polyfill script handle.

  | 
| [do_block_editor_incompatible_meta_box()](https://developer.wordpress.org/reference/functions/do_block_editor_incompatible_meta_box/)`wp-admin/includes/template.php` |

Renders a “fake” meta box with an information message, shown on the block editor, when an incompatible meta box is found.

  | 
| [wp_send_user_request()](https://developer.wordpress.org/reference/functions/wp_send_user_request/)`wp-includes/user.php` |

Send a confirmation request email to confirm an action.

  | 
| [WP_Privacy_Requests_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_privacy_requests_table/get_views/)`wp-admin/includes/class-wp-privacy-requests-table.php` |

Gets an associative array ( id => link ) with the list of views available on this table.

  | 
| [WP_Customize_Manager::handle_load_themes_request()](https://developer.wordpress.org/reference/classes/wp_customize_manager/handle_load_themes_request/)`wp-includes/class-wp-customize-manager.php` |

Loads themes into the theme browsing/installation UI.

  | 
| [wp_load_press_this()](https://developer.wordpress.org/reference/functions/wp_load_press_this/)`wp-admin/press-this.php` |  | 
| [wp_print_plugin_file_tree()](https://developer.wordpress.org/reference/functions/wp_print_plugin_file_tree/)`wp-admin/includes/misc.php` |

Outputs the formatted file list for the plugin file editor.

  | 
| [wp_print_theme_file_tree()](https://developer.wordpress.org/reference/functions/wp_print_theme_file_tree/)`wp-admin/includes/misc.php` |

Outputs the formatted file list for the theme file editor.

  | 
| [wp_edit_theme_plugin_file()](https://developer.wordpress.org/reference/functions/wp_edit_theme_plugin_file/)`wp-admin/includes/file.php` |

Attempts to edit a file for a theme or plugin.

  | 
| [WP_Customize_Manager::add_state_query_params()](https://developer.wordpress.org/reference/classes/wp_customize_manager/add_state_query_params/)`wp-includes/class-wp-customize-manager.php` |

Adds customize state query params to a given URL if preview is allowed.

  | 
| [WP_REST_Users_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_users_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php` |

Retrieves all users.

  | 
| [WP_REST_Revisions_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_revisions_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php` |

Gets a collection of revisions.

  | 
| [WP_REST_Post_Statuses_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_post_statuses_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php` |

Prepares a post status object for serialization.

  | 
| [WP_REST_Terms_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_terms_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php` |

Prepares links for the request.

  | 
| [WP_REST_Terms_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_terms_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php` |

Retrieves terms associated with a taxonomy.

  | 
| [WP_REST_Posts_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php` |

Prepares links for the request.

  | 
| [WP_REST_Posts_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php` |

Retrieves a collection of posts.

  | 
| [WP_REST_Comments_Controller::prepare_links()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/prepare_links/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Prepares links for the request.

  | 
| [WP_REST_Comments_Controller::get_items()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/get_items/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Retrieves a list of comment items.

  | 
| [wp_get_canonical_url()](https://developer.wordpress.org/reference/functions/wp_get_canonical_url/)`wp-includes/link-template.php` |

Returns the canonical URL for a post.

  | 
| [network_edit_site_nav()](https://developer.wordpress.org/reference/functions/network_edit_site_nav/)`wp-admin/includes/ms.php` |

Outputs the HTML for a network’s “Edit Site” tabular interface.

  | 
| [wp_ajax_search_install_plugins()](https://developer.wordpress.org/reference/functions/wp_ajax_search_install_plugins/)`wp-admin/includes/ajax-actions.php` |

Handles searching plugins to install via AJAX.

  | 
| [wp_ajax_search_plugins()](https://developer.wordpress.org/reference/functions/wp_ajax_search_plugins/)`wp-admin/includes/ajax-actions.php` |

Handles searching plugins via AJAX.

  | 
| [wp_ajax_install_theme()](https://developer.wordpress.org/reference/functions/wp_ajax_install_theme/)`wp-admin/includes/ajax-actions.php` |

Handles installing a theme via AJAX.

  | 
| [wp_ajax_install_plugin()](https://developer.wordpress.org/reference/functions/wp_ajax_install_plugin/)`wp-admin/includes/ajax-actions.php` |

Handles installing a plugin via AJAX.

  | 
| [get_rest_url()](https://developer.wordpress.org/reference/functions/get_rest_url/)`wp-includes/rest-api.php` |

Retrieves the URL to a REST endpoint on a site.

  | 
| [get_post_embed_url()](https://developer.wordpress.org/reference/functions/get_post_embed_url/)`wp-includes/embed.php` |

Retrieves the URL to embed a specific post in an iframe.

  | 
| [get_oembed_endpoint_url()](https://developer.wordpress.org/reference/functions/get_oembed_endpoint_url/)`wp-includes/embed.php` |

Retrieves the oEmbed endpoint URL for a given permalink.

  | 
| [WP_Customize_Manager::customize_pane_settings()](https://developer.wordpress.org/reference/classes/wp_customize_manager/customize_pane_settings/)`wp-includes/class-wp-customize-manager.php` |

Prints JavaScript settings for parent window.

  | 
| [get_preview_post_link()](https://developer.wordpress.org/reference/functions/get_preview_post_link/)`wp-includes/link-template.php` |

Retrieves the URL used for the post preview.

  | 
| [WP_Posts_List_Table::get_edit_link()](https://developer.wordpress.org/reference/classes/wp_posts_list_table/get_edit_link/)`wp-admin/includes/class-wp-posts-list-table.php` |

Creates a link to edit.php with params.

  | 
| [wp_admin_bar_customize_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_customize_menu/)`wp-includes/admin-bar.php` |

Adds the “Customize” link to the Toolbar.

  | 
| [WP_MS_Themes_List_Table::column_name()](https://developer.wordpress.org/reference/classes/wp_ms_themes_list_table/column_name/)`wp-admin/includes/class-wp-ms-themes-list-table.php` |

Handles the name column output.

  | 
| [WP_Terms_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_terms_list_table/handle_row_actions/)`wp-admin/includes/class-wp-terms-list-table.php` |

Generates and displays row action links.

  | 
| [WP_MS_Users_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/handle_row_actions/)`wp-admin/includes/class-wp-ms-users-list-table.php` |

Generates and displays row action links.

  | 
| [WP_MS_Users_List_Table::column_username()](https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/column_username/)`wp-admin/includes/class-wp-ms-users-list-table.php` |

Handles the username column output.

  | 
| [WP_Media_List_Table::column_author()](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_author/)`wp-admin/includes/class-wp-media-list-table.php` |

Handles the author column output.

  | 
| [WP_Media_List_Table::column_parent()](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_parent/)`wp-admin/includes/class-wp-media-list-table.php` |

Handles the parent column output.

  | 
| [WP_Media_List_Table::column_default()](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_default/)`wp-admin/includes/class-wp-media-list-table.php` |

Handles output for the default column.

  | 
| [get_avatar_data()](https://developer.wordpress.org/reference/functions/get_avatar_data/)`wp-includes/link-template.php` |

Retrieves default data about the avatar.

  | 
| [wp_media_attach_action()](https://developer.wordpress.org/reference/functions/wp_media_attach_action/)`wp-admin/includes/media.php` |

Encapsulates the logic for Attach/Detach actions.

  | 
| [wp_prepare_themes_for_js()](https://developer.wordpress.org/reference/functions/wp_prepare_themes_for_js/)`wp-admin/includes/theme.php` |

Prepares themes for JavaScript.

  | 
| [get_theme_update_available()](https://developer.wordpress.org/reference/functions/get_theme_update_available/)`wp-admin/includes/theme.php` |

Retrieves the update link if there is a theme update available.

  | 
| [themes_api()](https://developer.wordpress.org/reference/functions/themes_api/)`wp-admin/includes/theme.php` |

Retrieves theme installer pages from the WordPress.org Themes API.

  | 
| [WP_Plugins_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_plugins_list_table/get_views/)`wp-admin/includes/class-wp-plugins-list-table.php` |  | 
| [WP_Plugins_List_Table::single_row()](https://developer.wordpress.org/reference/classes/wp_plugins_list_table/single_row/)`wp-admin/includes/class-wp-plugins-list-table.php` |  | 
| [WP_Plugins_List_Table::__construct()](https://developer.wordpress.org/reference/classes/wp_plugins_list_table/__construct/)`wp-admin/includes/class-wp-plugins-list-table.php` |

Constructor.

  | 
| [Theme_Upgrader_Skin::after()](https://developer.wordpress.org/reference/classes/theme_upgrader_skin/after/)`wp-admin/includes/class-theme-upgrader-skin.php` |

Performs an action following a single theme update.

  | 
| [Theme_Installer_Skin::after()](https://developer.wordpress.org/reference/classes/theme_installer_skin/after/)`wp-admin/includes/class-theme-installer-skin.php` |

Performs an action following a single theme install.

  | 
| [WP_List_Table::view_switcher()](https://developer.wordpress.org/reference/classes/wp_list_table/view_switcher/)`wp-admin/includes/class-wp-list-table.php` |

Displays a view switcher.

  | 
| [WP_List_Table::comments_bubble()](https://developer.wordpress.org/reference/classes/wp_list_table/comments_bubble/)`wp-admin/includes/class-wp-list-table.php` |

Displays a comment count bubble.

  | 
| [WP_List_Table::pagination()](https://developer.wordpress.org/reference/classes/wp_list_table/pagination/)`wp-admin/includes/class-wp-list-table.php` |

Displays the pagination.

  | 
| [WP_List_Table::print_column_headers()](https://developer.wordpress.org/reference/classes/wp_list_table/print_column_headers/)`wp-admin/includes/class-wp-list-table.php` |

Prints column headers, accounting for hidden and sortable columns.

  | 
| [WP_List_Table::set_pagination_args()](https://developer.wordpress.org/reference/classes/wp_list_table/set_pagination_args/)`wp-admin/includes/class-wp-list-table.php` |

Sets all the necessary pagination arguments.

  | 
| [WP_MS_Themes_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_ms_themes_list_table/get_views/)`wp-admin/includes/class-wp-ms-themes-list-table.php` |  | 
| [set_screen_options()](https://developer.wordpress.org/reference/functions/set_screen_options/)`wp-admin/includes/misc.php` |

Saves option for number of rows when listing posts, pages, comments, etc.

  | 
| [WP_Theme_Install_List_Table::install_theme_info()](https://developer.wordpress.org/reference/classes/wp_theme_install_list_table/install_theme_info/)`wp-admin/includes/class-wp-theme-install-list-table.php` |

Prints the info for a theme (to be used in the theme installer modal).

  | 
| [WP_Theme_Install_List_Table::single_row()](https://developer.wordpress.org/reference/classes/wp_theme_install_list_table/single_row/)`wp-admin/includes/class-wp-theme-install-list-table.php` |

Prints a theme from the WordPress.org API.

  | 
| [wp_plugin_update_row()](https://developer.wordpress.org/reference/functions/wp_plugin_update_row/)`wp-admin/includes/update.php` |

Displays update information for a plugin.

  | 
| [wp_theme_update_row()](https://developer.wordpress.org/reference/functions/wp_theme_update_row/)`wp-admin/includes/update.php` |

Displays update information for a theme.

  | 
| [install_plugin_information()](https://developer.wordpress.org/reference/functions/install_plugin_information/)`wp-admin/includes/plugin-install.php` |

Displays plugin information in dialog box form.

  | 
| [plugins_api()](https://developer.wordpress.org/reference/functions/plugins_api/)`wp-admin/includes/plugin-install.php` |

Retrieves plugin installer pages from the WordPress.org Plugins API.

  | 
| [wp_dashboard_browser_nag()](https://developer.wordpress.org/reference/functions/wp_dashboard_browser_nag/)`wp-admin/includes/dashboard.php` |

Displays the browser update nag.

  | 
| [wp_add_dashboard_widget()](https://developer.wordpress.org/reference/functions/wp_add_dashboard_widget/)`wp-admin/includes/dashboard.php` |

Adds a new dashboard widget.

  | 
| [menu_page_url()](https://developer.wordpress.org/reference/functions/menu_page_url/)`wp-admin/includes/plugin.php` |

Gets the URL to access a particular menu page based on the slug it was registered with.

  | 
| [activate_plugin()](https://developer.wordpress.org/reference/functions/activate_plugin/)`wp-admin/includes/plugin.php` |

Attempts activation of plugin in a “sandbox” and redirects on success.

  | 
| [activate_plugins()](https://developer.wordpress.org/reference/functions/activate_plugins/)`wp-admin/includes/plugin.php` |

Activates multiple plugins.

  | 
| [WP_Users_List_Table::single_row()](https://developer.wordpress.org/reference/classes/wp_users_list_table/single_row/)`wp-admin/includes/class-wp-users-list-table.php` |

Generates HTML for a single row on the users.php admin panel.

  | 
| [WP_Users_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_users_list_table/get_views/)`wp-admin/includes/class-wp-users-list-table.php` |

Returns an associative array listing all the views that can be used with this table.

  | 
| [media_upload_library_form()](https://developer.wordpress.org/reference/functions/media_upload_library_form/)`wp-admin/includes/media.php` |

Outputs the legacy media upload form for the media library.

  | 
| [the_media_upload_tabs()](https://developer.wordpress.org/reference/functions/the_media_upload_tabs/)`wp-admin/includes/media.php` |

Outputs the legacy media upload tabs UI.

  | 
| [get_upload_iframe_src()](https://developer.wordpress.org/reference/functions/get_upload_iframe_src/)`wp-admin/includes/media.php` |

Retrieves the upload iframe source URL.

  | 
| [_admin_notice_post_locked()](https://developer.wordpress.org/reference/functions/_admin_notice_post_locked/)`wp-admin/includes/post.php` |

Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post.

  | 
| [wp_ajax_query_themes()](https://developer.wordpress.org/reference/functions/wp_ajax_query_themes/)`wp-admin/includes/ajax-actions.php` |

Handles getting themes from [themes_api()](https://developer.wordpress.org/reference/functions/themes_api/) via AJAX.

  | 
| [wp_prepare_revisions_for_js()](https://developer.wordpress.org/reference/functions/wp_prepare_revisions_for_js/)`wp-admin/includes/revision.php` |

Prepare revisions for JavaScript.

  | 
| [post_submit_meta_box()](https://developer.wordpress.org/reference/functions/post_submit_meta_box/)`wp-admin/includes/meta-boxes.php` |

Displays post submit form fields.

  | 
| [WP_Comments_List_Table::column_author()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/column_author/)`wp-admin/includes/class-wp-comments-list-table.php` |  | 
| [WP_Comments_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/get_views/)`wp-admin/includes/class-wp-comments-list-table.php` |  | 
| [WP_Terms_List_Table::column_name()](https://developer.wordpress.org/reference/classes/wp_terms_list_table/column_name/)`wp-admin/includes/class-wp-terms-list-table.php` |  | 
| [WP_Terms_List_Table::column_posts()](https://developer.wordpress.org/reference/classes/wp_terms_list_table/column_posts/)`wp-admin/includes/class-wp-terms-list-table.php` |  | 
| [Walker_Nav_Menu_Edit::start_el()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/functions/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()](https://developer.wordpress.org/reference/functions/wp_nav_menu_item_taxonomy_meta_box/)`wp-admin/includes/nav-menu.php` |

Displays a meta box for a taxonomy menu item.

  | 
| [wp_widget_control()](https://developer.wordpress.org/reference/functions/wp_widget_control/)`wp-admin/includes/widgets.php` |

Meta widget used to display the control form for a widget.

  | 
| [WP_Posts_List_Table::get_views()](https://developer.wordpress.org/reference/classes/wp_posts_list_table/get_views/)`wp-admin/includes/class-wp-posts-list-table.php` |  | 
| [wp_get_popular_importers()](https://developer.wordpress.org/reference/functions/wp_get_popular_importers/)`wp-admin/includes/import.php` |

Returns a list from WordPress.org of popular importer plugins.

  | 
| [Custom_Image_Header::step_1()](https://developer.wordpress.org/reference/classes/custom_image_header/step_1/)`wp-admin/includes/class-custom-image-header.php` |

Displays first step of custom header image page.

  | 
| [Custom_Image_Header::step_2()](https://developer.wordpress.org/reference/classes/custom_image_header/step_2/)`wp-admin/includes/class-custom-image-header.php` |

Displays second step of custom header image page.

  | 
| [redirect_post()](https://developer.wordpress.org/reference/functions/redirect_post/)`wp-admin/includes/post.php` |

Redirects to previous page.

  | 
| [_wp_menu_output()](https://developer.wordpress.org/reference/functions/_wp_menu_output/)`wp-admin/menu-header.php` |

Display menu.

  | 
| [WP_Styles::_css_href()](https://developer.wordpress.org/reference/classes/wp_styles/_css_href/)`wp-includes/class-wp-styles.php` |

Generates an enqueued style’s fully-qualified URL.

  | 
| [spawn_cron()](https://developer.wordpress.org/reference/functions/spawn_cron/)`wp-includes/cron.php` |

Sends a request to run cron through HTTP request that doesn’t halt page loading.

  | 
| [wp_customize_url()](https://developer.wordpress.org/reference/functions/wp_customize_url/)`wp-includes/theme.php` |

Returns a URL to load the Customizer.

  | 
| [wp_admin_css_uri()](https://developer.wordpress.org/reference/functions/wp_admin_css_uri/)`wp-includes/general-template.php` |

Displays the URL of a WordPress admin CSS file.

  | 
| [paginate_links()](https://developer.wordpress.org/reference/functions/paginate_links/)`wp-includes/general-template.php` |

Retrieves paginated links for archive post pages.

  | 
| [wp_get_archives()](https://developer.wordpress.org/reference/functions/wp_get_archives/)`wp-includes/general-template.php` |

Displays archive links based on type and format.

  | 
| [wp_logout_url()](https://developer.wordpress.org/reference/functions/wp_logout_url/)`wp-includes/general-template.php` |

Retrieves the logout URL.

  | 
| [wp_login_url()](https://developer.wordpress.org/reference/functions/wp_login_url/)`wp-includes/general-template.php` |

Retrieves the login URL.

  | 
| [wp_lostpassword_url()](https://developer.wordpress.org/reference/functions/wp_lostpassword_url/)`wp-includes/general-template.php` |

Returns the URL that allows the user to reset the lost password.

  | 
| [dropdown_cats()](https://developer.wordpress.org/reference/functions/dropdown_cats/)`wp-includes/deprecated.php` |

Deprecated method for generating a drop-down of categories.

  | 
| [wp_get_links()](https://developer.wordpress.org/reference/functions/wp_get_links/)`wp-includes/deprecated.php` |

Gets the links associated with category.

  | 
| [wp_auth_check_html()](https://developer.wordpress.org/reference/functions/wp_auth_check_html/)`wp-includes/functions.php` |

Outputs the HTML that shows the wp-login dialog when the user is no longer logged in.

  | 
| [wp_nonce_url()](https://developer.wordpress.org/reference/functions/wp_nonce_url/)`wp-includes/functions.php` |

Retrieves URL with nonce added to URL query.

  | 
| [remove_query_arg()](https://developer.wordpress.org/reference/functions/remove_query_arg/)`wp-includes/functions.php` |

Removes an item or items from a query string.

  | 
| [get_comments_pagenum_link()](https://developer.wordpress.org/reference/functions/get_comments_pagenum_link/)`wp-includes/link-template.php` |

Retrieves the comments page number link.

  | 
| [paginate_comments_links()](https://developer.wordpress.org/reference/functions/paginate_comments_links/)`wp-includes/link-template.php` |

Displays or retrieves pagination links for the comments on the current post.

  | 
| [get_pagenum_link()](https://developer.wordpress.org/reference/functions/get_pagenum_link/)`wp-includes/link-template.php` |

Retrieves the link for a page number.

  | 
| [get_edit_user_link()](https://developer.wordpress.org/reference/functions/get_edit_user_link/)`wp-includes/link-template.php` |

Retrieves the edit user link.

  | 
| [get_search_comments_feed_link()](https://developer.wordpress.org/reference/functions/get_search_comments_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the search results comments feed.

  | 
| [get_post_type_archive_feed_link()](https://developer.wordpress.org/reference/functions/get_post_type_archive_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for a post type archive feed.

  | 
| [get_delete_post_link()](https://developer.wordpress.org/reference/functions/get_delete_post_link/)`wp-includes/link-template.php` |

Retrieves the delete posts link for post.

  | 
| [get_edit_term_link()](https://developer.wordpress.org/reference/functions/get_edit_term_link/)`wp-includes/link-template.php` |

Retrieves the URL for editing a given term.

  | 
| [get_search_feed_link()](https://developer.wordpress.org/reference/functions/get_search_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the search results feed.

  | 
| [get_post_comments_feed_link()](https://developer.wordpress.org/reference/functions/get_post_comments_feed_link/)`wp-includes/link-template.php` |

Retrieves the permalink for the post comments feed.

  | 
| [get_post_permalink()](https://developer.wordpress.org/reference/functions/get_post_permalink/)`wp-includes/link-template.php` |

Retrieves the permalink for a post of a custom post type.

  | 
| [WP_oEmbed::fetch()](https://developer.wordpress.org/reference/classes/wp_oembed/fetch/)`wp-includes/class-wp-oembed.php` |

Connects to an oEmbed provider and returns the result.

  | 
| [WP_oEmbed::_fetch_with_format()](https://developer.wordpress.org/reference/classes/wp_oembed/_fetch_with_format/)`wp-includes/class-wp-oembed.php` |

Fetches result from an oEmbed provider for a specific format and complete provider URL

  | 
| [_wp_link_page()](https://developer.wordpress.org/reference/functions/_wp_link_page/)`wp-includes/post-template.php` |

Helper function for [wp_link_pages()](https://developer.wordpress.org/reference/functions/wp_link_pages/) .

  | 
| [wp_enqueue_media()](https://developer.wordpress.org/reference/functions/wp_enqueue_media/)`wp-includes/media.php` |

Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs.

  | 
| [wp_video_shortcode()](https://developer.wordpress.org/reference/functions/wp_video_shortcode/)`wp-includes/media.php` |

Builds the Video shortcode output.

  | 
| [wp_audio_shortcode()](https://developer.wordpress.org/reference/functions/wp_audio_shortcode/)`wp-includes/media.php` |

Builds the Audio shortcode output.

  | 
| [WP_Rewrite::add_rule()](https://developer.wordpress.org/reference/classes/wp_rewrite/add_rule/)`wp-includes/class-wp-rewrite.php` |

Adds a rewrite rule that transforms a URL structure to a set of query vars.

  | 
| [redirect_canonical()](https://developer.wordpress.org/reference/functions/redirect_canonical/)`wp-includes/canonical.php` |

Redirects incoming links to the proper URL based on the site url.

  | 
| [_post_format_link()](https://developer.wordpress.org/reference/functions/_post_format_link/)`wp-includes/post-formats.php` |

Filters the post format term link to remove the format prefix.

  | 
| [WP_Scripts::do_item()](https://developer.wordpress.org/reference/classes/wp_scripts/do_item/)`wp-includes/class-wp-scripts.php` |

Processes a script dependency.

  | 
| [get_comment_reply_link()](https://developer.wordpress.org/reference/functions/get_comment_reply_link/)`wp-includes/comment-template.php` |

Retrieves HTML content for reply to comment link.

  | 
| [get_comment_link()](https://developer.wordpress.org/reference/functions/get_comment_link/)`wp-includes/comment-template.php` |

Retrieves the link to a given comment.

  | 
| [wp_style_loader_src()](https://developer.wordpress.org/reference/functions/wp_style_loader_src/)`wp-includes/script-loader.php` |

Administration Screen CSS for changing the styles.

  | 
| [wp_print_media_templates()](https://developer.wordpress.org/reference/functions/wp_print_media_templates/)`wp-includes/media-template.php` |

Prints the templates used in the media manager.

  |

[Show 158 more](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.3.0](https://developer.wordpress.org/reference/since/5.3.0/) | Formalized the existing and already documented parameters by adding `...$args` to the function signature. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 8 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-260)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-260)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-260)
     Vote results for this note: 23[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-260)
 4.  Assuming we’re at the WordPress URL “http://blog.example.com/client/?s=word”… 
     Note the use of `esc_url()` before outputting the link. This is necessary because
     this function does not escape URLs and if output without escaping, would make 
     the page vulnerable to XSS scripting.
 5.      ```php
         // This would output '/client/?s=word&foo=bar'
         echo esc_url( add_query_arg( 'foo', 'bar' ) );
     
         // This would output '/client/?s=word&foo=bar&baz=tiny'
         $arr_params = array( 'foo' => 'bar', 'baz' => 'tiny' );
         echo esc_url( add_query_arg( $arr_params ) );
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D260%23feedback-editor-260)
 7.   [Skip to note 9 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-1328)
 8.    [Ahmad Awais](https://profiles.wordpress.org/mrahmadawais/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-1328)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-1328)
     Vote results for this note: 6[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-1328)
 10. To safely redirect user to a custom page inside `plugins.php`
 11.     ```php
         // Redirect to Welcome Page.
         // Redirects to your-domain.com/wp-admin/plugin.php?page=your_plugin_page.
         wp_safe_redirect( add_query_arg( array( 'page' => 'your_plugin_page' ), admin_url( 'plugins.php' ) ) );
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D1328%23feedback-editor-1328)
 13.  [Skip to note 10 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-262)
 14.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-262)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-262)
     Vote results for this note: 5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-262)
 16. Since `get_permalink()` returns a full URL, you could use that when you want to
     add variables to a post’s page.
 17.     ```php
         /*
          * This would output whatever the URL to post ID 9 is, with 'hello=there'
          * appended with either ? or &, depending on what's needed.
          */
         echo esc_url( add_query_arg( 'hello', 'there', get_permalink( 9 ) ) );
         ```
     
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D262%23feedback-editor-262)
 19.  [Skip to note 11 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-261)
 20.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-261)
 21. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-261)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-261)
 22. More often than not you’ll probably find yourself creating URLs using the following
     method within the page you’re currently on. In these cases you can use the URL
     you want to affect as the last parameter. The use of `esc_url()` is not required
     here, because the value is known to be safe.
 23.     ```php
         // This would output 'http://blog.example.com/2009/04/16/?hello=world'
         echo esc_url( add_query_arg( 'hello', 'world', 'http://blog.example.com/2009/04/16/' ) );
         ```
     
 24.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D261%23feedback-editor-261)
 25.  [Skip to note 12 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-263)
 26.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-263)
 27. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-263)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-263)
 28. Removing values and setting via an associative array:
 29.     ```php
         $query = 'http://example.com/link?foo=bar';
         $new_query = add_query_arg( array(
         	'foo' => false,
         	'baz' => 'qux'
         ), $query );
         print( $new_query );
         // http://example.com/link?baz=qux
         ```
     
 30.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D263%23feedback-editor-263)
 31.  [Skip to note 13 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-4789)
 32.   [rlabrovi](https://profiles.wordpress.org/gardelin/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-4789)
 33. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-4789)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-4789)
 34. If query string value is ending with `==` one `=` is stripped out.
 35.     ```php
         add_query_arg( array( 'something' => 'blabla==' ), 'https://www.google.com' );
         ```
     
 36. Result will be
      `https://www.google.com?something=blabla=` but should be `https://
     www.google.com?something=blabla==`
 37.  * and if [‘something’]’s value starts with a doublequote, as in `?something="
        else here"` the equals sign is suppressed…izzat a bug or a feature?
      * [airdrummer](https://profiles.wordpress.org/airdrummer/) [1 year ago](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-7245)
 38.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D4789%23feedback-editor-4789)
 39.  [Skip to note 14 content](https://developer.wordpress.org/reference/functions/add_query_arg/?output_format=md#comment-content-1057)
 40.   [Jan-Willem](https://profiles.wordpress.org/janwoostendorp/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-1057)
 41. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-1057)
     Vote results for this note: -4[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%23comment-1057)
 42. A way to get the current total url using `add_query_arg`
 43.     ```php
         home_url( add_query_arg( null, null ));
         ```
     
 44.  * This does not work if WordPress has been installed in a subfolder and siteurl
        contains a subfolder like `https://domain.com/subfolder` In your example, this
        would repeat the arguments like `https://domain.com/subfolder/subfolder` Correct
        code would be home_url( add_query_arg( null, null, null )); Or even better 
        just use `network_site_url()` instead.
      * [Rene Hermenau](https://profiles.wordpress.org/renehermi/) [7 years ago](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-3066)
      * Another way to get the current url is:
      *     ```php
            $current_path = add_query_arg(array());
            ```
        
      *  This is equivalent to setting `$key` and `$value` parameters to `null`, and
        not providing a `$url` parameter. Thus, it returns the current url, having 
        appended nothing to it.
      * [SherylHohman](https://profiles.wordpress.org/sherylhohman/) [7 years ago](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-3226)
      * This will not work if WordPress is installed to a sub-directory. Both [home_url()](https://developer.wordpress.org/reference/functions/home_url/)
        and [add_query_arg()](https://developer.wordpress.org/reference/functions/add_query_arg/)
        return the directory. I think this would be better: `'//' . $_SERVER['HTTP_HOST'].
        add_query_arg( null, null )`
      * [mjulian7](https://profiles.wordpress.org/mjulian7/) [7 years ago](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-3297)
      * Another way: `$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['
        REQUEST_URI'];`
      * [Álvaro Franz](https://profiles.wordpress.org/alvarofranz/) [3 years ago](https://developer.wordpress.org/reference/functions/add_query_arg/#comment-6194)
 45.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F%3Freplytocom%3D1057%23feedback-editor-1057)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_query_arg%2F)
before being able to contribute a note or feedback.