build_query() WordPress Function

The build_query() function is used to generate a URL-encoded query string from an array of data. This function can be useful when you need to create a link to another page with a query string that contains multiple parameters.

build_query( array $data ) #

Build URL query based on an associative and, or indexed array.


Description

This is a convenient function for easily building url queries. It sets the separator to ‘&’ and uses _http_build_query() function.

Top ↑

See also


Top ↑

Parameters

$data

(array)(Required)URL-encode key/value pairs.


Top ↑

Return

(string) URL-encoded string.


Top ↑

Source

File: wp-includes/functions.php

function build_query( $data ) {
	return _http_build_query( $data, null, '&', '', false );
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More