How to modify WordPress REST API response

2019-09-13 10:23发布

问题:

I am really really new to WordPress and I just I installed the REST API.

I am not satisfied with the default response and I want to modify it to fit the purpose I'm using it for.

I prefer the way this link modified it's response. Particularly, the "author" object details were returned in the response.

In this other blog , REST API is returning the default response. Here, "author" is an array in "_links" object. And it doesn't even contain the details of the author, just a link to it.

My question is how do I make my own plugin return the details of the author instead of the link, like the way first link did it?

回答1:

Ahmad Awais here, you linked my site and I am using the older version of the REST API Version 1 which came first, but am definitely going to move to the Version 2. You can try it out as well.