rest_get_queried_resource_route example


function rest_output_link_wp_head() {
    $api_root = get_rest_url();

    if ( empty( $api_root ) ) {
        return;
    }

    printf( '<link rel="https://api.w.org/" href="%s" />', esc_url( $api_root ) );

    $resource = rest_get_queried_resource_route();

    if ( $resource ) {
        printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) );
    }
}

/** * Sends a Link header for the REST API. * * @since 4.4.0 */
Home | Imprint | This part of the site doesn't use cookies.