【问题标题】:WordPress acf-to-rest-api && Rest APIWordPress acf-to-rest-api && Rest API
【发布时间】:2017-09-12 10:49:20
【问题描述】:

将 ACF 激活为 REST API,破坏 WP REST API

如果我激活 WP REST API,我可以检索数据:(目前在网站上都启用了,所以链接会显示错误)

http://ecommerce-ux.london/wp-json/wp/v2/posts?slug=hello-world

http://ecommerce-ux.london/wp-json/wp/v2/posts/1

当前错误响应是

<br />
<b>Fatal error</b>:  Using $this when not in object context in <b>/home/commercect/public_html/wp-content/plugins/acf-to-rest-api-master/v3/lib/endpoints/class-acf-to-rest-api-controller.php</b> on line <b>54</b><br />

以上链接不起作用,但如果我这样做: http://ecommerce-ux.london/wp-json/wp/v2 它给了我 api 调用。

由于我需要为我的单个帖子页面检索自定义字段,我已将 ACF 设置为 Rest API,但这会破坏我的 wp/2 插件端点,我无法再检索数据,但 ACF 确实有效:

http://ecommerce-ux.london/wp-json/acf/v3/posts/1

回复是

{"acf":{"":false,"anchor":[{"anchor_name":"Heading","anchor_link":"heading-name"}]}}

插件

WP REST API 用于 WordPress 的基于 SON 的 REST API 版本 2.0-beta15 |通过 WP REST API 团队 http://v2.wp-api.org/

ACF 到 REST API 版本 3.0.1-beta |通过艾雷斯贡萨尔维斯 | https://github.com/airesvsg/acf-to-rest-api

有人知道解决办法吗?

【问题讨论】:

    标签: wordpress advanced-custom-fields wordpress-rest-api


    【解决方案1】:

    在这里找到一个例子后; http://airesgoncalves.com.br/acf-to-rest-api/wp-json/acf/v2/post/1

    整理好了!不要使用来自 github 的插件。使用来自 WP.org 页面的那个。 https://wordpress.org/plugins/acf-to-rest-api/

    【讨论】:

      猜你喜欢
      • 2019-10-26
      • 2022-08-17
      • 2023-03-15
      • 2016-04-12
      • 2019-01-12
      • 2017-08-20
      • 2021-06-11
      • 2023-03-19
      • 2016-04-20
      相关资源
      最近更新 更多