【问题标题】:ACF Rest Api - Categories Return Value Term Object Not workingACF Rest Api - 类别返回值术语对象不工作
【发布时间】:2022-12-21 05:17:30
【问题描述】:

我试图返回一个包含类别中值的对象,但 ACF 只返回一个键数组。

帮助?

Example of return value & settings

【问题讨论】:

  • 为什么关闭“在 REST API 中显示”?
  • 这就是 ACF 的设置。我使用了另一个插件(JasmanXcrew 的 REST API Helper)来让 REST api 工作。我最终在 WordPress 中创建了自己的 REST Route 来解决这个问题。不确定为什么它只返回键,但它应该返回一个值对象......
  • 顺便说一下,我也尝试过在 REST Api 中使用默认显示,它返回一个键数组。

标签: wordpress rest frontend advanced-custom-fields


【解决方案1】:

默认情况下,ACF 不考虑 REST API 响应中字段的“返回值”选择,但如果您将 acf_format=standard 查询参数添加到您的请求中,它就会考虑返回值选项。

/wp-json/wp/v2/post?acf_format=standard

有关查询参数的文档:

https://www.advancedcustomfields.com/resources/wp-rest-api-integration/#controlling-output-format

【讨论】:

    猜你喜欢
    • 2019-11-26
    • 1970-01-01
    • 2017-10-11
    • 2015-02-13
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-09
    • 2017-06-22
    相关资源
    最近更新 更多