rest_url() WordPress Function

The rest_url() function is used to retrieve the URL of the REST API. This function is useful for making REST API calls from JavaScript or other programming languages. The URL returned by this function can be used to access the WordPress REST API.

rest_url( string $path = '', string $scheme = 'rest' ) #

Retrieves the URL to a REST endpoint.


Description

Note: The returned URL is NOT escaped.


Top ↑

Parameters

$path

(string)(Optional) REST route.

Default value: ''

$scheme

(string)(Optional) Sanitization scheme.

Default value: 'rest'


Top ↑

Return

(string) Full URL to the endpoint.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_url( $path = '', $scheme = 'rest' ) {
	return get_rest_url( null, $path, $scheme );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.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