On this page
rest_get_queried_resource_route(): string
Gets the REST route for the currently queried object.
Return
string The REST route of the resource, or an empty string if no resource identified.
Source
File: wp-includes/rest-api.php. View all references
function rest_get_queried_resource_route() {
if ( is_singular() ) {
$route = rest_get_route_for_post( get_queried_object() );
} elseif ( is_category() || is_tag() || is_tax() ) {
$route = rest_get_route_for_term( get_queried_object() );
} elseif ( is_author() ) {
$route = '/wp/v2/users/' . get_queried_object_id();
} else {
$route = '';
}
/**
* Filters the REST route for the currently queried object.
*
* @since 5.5.0
*
* @param string $link The route with a leading slash, or an empty string.
*/
return apply_filters( 'rest_queried_resource_route', $route );
}
Hooks
- apply_filters( 'rest_queried_resource_route',
string $link ) -
Filters the REST route for the currently queried object.
Related
Uses
| Uses | Description |
|---|---|
| rest_get_route_for_post() wp-includes/rest-api.php | Gets the REST API route for a post. |
| rest_get_route_for_term() wp-includes/rest-api.php | Gets the REST API route for a term. |
| is_singular() wp-includes/query.php | Determines whether the query is for an existing single post of any post type (post, attachment, page, custom post types). |
| is_category() wp-includes/query.php | Determines whether the query is for an existing category archive page. |
| is_tag() wp-includes/query.php | Determines whether the query is for an existing tag archive page. |
| is_tax() wp-includes/query.php | Determines whether the query is for an existing custom taxonomy archive page. |
| is_author() wp-includes/query.php | Determines whether the query is for an existing author archive page. |
| get_queried_object() wp-includes/query.php | Retrieves the currently queried object. |
| get_queried_object_id() wp-includes/query.php | Retrieves the ID of the currently queried object. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| rest_output_link_wp_head() wp-includes/rest-api.php | Outputs the REST API link tag into page header. |
| rest_output_link_header() wp-includes/rest-api.php | Sends a Link header for the REST API. |
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_get_queried_resource_route