rest_url( string $path = '', string $scheme = 'rest' )
Retrieves the URL to a REST endpoint.
Description #Description
Note: The returned URL is NOT escaped.
Parameters #Parameters
- $path
-
(string) (Optional) REST route.
Default value: ''
- $scheme
-
(string) (Optional) Sanitization scheme.
Default value: 'rest'
Return #Return
(string) Full URL to the endpoint.
Source #Source
File: wp-includes/rest-api.php
function rest_url( $path = '', $scheme = 'rest' ) { return get_rest_url( null, $path, $scheme ); }
Expand full source code Collapse full source code View on Trac
Changelog #Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
Related #Related
Uses #Uses
Uses | Description |
---|---|
wp-includes/rest-api.php: get_rest_url() |
Retrieves the URL to a REST endpoint on a site. |
Used By #Used By
Used By | Description |
---|---|
wp-admin/includes/class-wp-site-health.php: WP_Site_Health::get_test_rest_availability() |
Test if the REST API is accessible. |
wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php: WP_REST_Search_Controller::get_items() |
Retrieves a collection of search results. |
wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php: WP_REST_Search_Controller::prepare_item_for_response() |
Prepares a single search result for response. |
wp-includes/rest-api/search/class-wp-rest-post-search-handler.php: WP_REST_Post_Search_Handler::prepare_item_links() |
Prepares links for the search result of a given ID. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_schema_links() |
Retrieve Link Description Objects that should be added to the Schema for the posts collection. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::prepare_links() |
Prepares links for the user request. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::create_item() |
Creates a single user. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::get_items() |
Retrieves all users. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::prepare_item_for_response() |
Prepares the revision for the REST response. |
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php: WP_REST_Revisions_Controller::get_items() |
Gets a collection of revisions. |
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::create_item() |
Creates a single attachment. |
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php: WP_REST_Post_Statuses_Controller::prepare_item_for_response() |
Prepares a post status object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::create_item() |
Creates a single term in a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php: WP_REST_Terms_Controller::get_items() |
Retrieves terms associated with a taxonomy. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::create_item() |
Creates a single post. |
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php: WP_REST_Posts_Controller::get_items() |
Retrieves a collection of posts. |
wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php: WP_REST_Taxonomies_Controller::prepare_item_for_response() |
Prepares a taxonomy object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php: WP_REST_Post_Types_Controller::prepare_item_for_response() |
Prepares a post type object for serialization. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::prepare_links() |
Prepares links for the request. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::create_item() |
Creates a comment. |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php: WP_REST_Comments_Controller::get_items() |
Retrieves a list of comment items. |
wp-includes/rest-api/class-wp-rest-request.php: WP_REST_Request::from_url() |
Retrieves a WP_REST_Request object from a full URL. |
wp-includes/embed.php: get_oembed_endpoint_url() |
Retrieves the oEmbed endpoint URL for a given permalink. |
wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_data_for_route() |
Retrieves publicly-visible data for the route. |
wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::get_namespace_index() |
Retrieves the index for a namespace. |
wp-includes/media.php: wp_enqueue_media() |
Enqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. |
User Contributed Notes #User Contributed Notes
You must log in before being able to contribute a note or feedback.
As an example, to get the rest endpoint for a given post: