<?php
/**
* Grab latest post title by an author!
*
* @param array $data Options for the function.
* @return string|null Post title for the latest,
* or null if none.
*/
function my_awesome_func(WP_REST_Request $request) {
$parameters = $request->get_params();
var_export($parameters);
// The individual sets of parameters are also available, if needed:
$parameters = $request->get_url_params();
var_export($parameters);
$parameters = $request->get_query_params();
var_export($parameters);
}
add_action('rest_api_init', function () {
register_rest_route('myplugin/v1', '/author/(?P<id>\d+)', array(
'methods' => 'GET',
'callback' => 'my_awesome_func',
));
});
?>