【问题标题】:Include postmeta in wordpress rest api在 wordpress rest api 中包含 postmeta
【发布时间】: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


【解决方案1】:

上面的代码或多或少会起作用,但是通过this plugin 有选择地公开您的postmeta 的更简单和优雅的方法可能是。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-20
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 2016-04-03
    相关资源
    最近更新 更多