【发布时间】:2017-07-28 12:21:03
【问题描述】:
我正在尝试在 json 响应中包含 postmeta。我已经在这里得到了代码:
https://torquemag.io/2015/07/working-with-post-meta-data-using-the-wordpress-rest-api/
我的问题是在哪里添加此代码?我最初的想法是将它们添加到主题内的functions.php中。或者我应该将它添加到 wp-includes 中的 functions.php 中吗?
更新: 我在 rest-api 的 plugin.php 中添加了代码,它起作用了。这是首选方法吗?还是有更好的方法?
【问题讨论】:
-
你应该添加主题functions.php
-
我在 rest-api 的 plugin.php 中添加了它并且它工作。应该有区别吗?
标签: php wordpress wordpress-rest-api