The default content at /wp-json/ contains name, description, url etc. but I want to add some additional content at this root level.

I see lots of ways to modify the responses of items with object types but am missing how to modify the main index.

It appears I want to modify the $available array of the get_index function of /wp-includes/rest-api/class-wp-rest-server.php/ but I'm just not sure how to filter/hook that.

| improve this question | | | | |
function filterResponse($response){
  $data = $response->data;
  $data['extra_field'] = 'some data';
  return $response;

add_filter('rest_index', 'filterResponse');

Thanks to Jeff

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.