【发布时间】: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