admin管理员组文章数量:1326638
I'm modifying the WP REST API for mobile app usage, and I went through at the first registering new fields route using the rest_api_init
action or hook using the func register_rest_field
, but I found there's a lot of fields I don't need it or wanted so I get rid of it by using the filter rest_prepare_post
What I found out is I can actually add new fields in my filter by modifying the data array and no needs for the rest_api_init
or register_rest_field
at all.
So what I am asking is what is the best approach for doing this? is it good to add and remove fields in one function instead of two? I'm now using both register_route_field
for the new fields and unset
all the unnecessary fields
by rest_prepare_post
本文标签: phpwhat is the best practice to add new field to an api route
版权声明:本文标题:php - what is the best practice to add new field to an api route 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742206781a2432965.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论