WordPress acf-to-rest-api && 休息 API

WordPress acf-to-rest-api && Rest API

激活 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 个电话。

因为我需要为我的单个 post 页面检索自定义字段,所以我将 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 休息 API 基于 SON 的 REST API for WordPress 版本 2.0-beta15 |作者:WP REST API 团队 http://v2.wp-api.org/

ACF 到 REST API 版本 3.0.1-beta |作者:Aires Gonçalves | https://github.com/airesvsg/acf-to-rest-api

有人知道解决方法吗?

在这里找到例子后; 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/