【发布时间】:2019-09-19 10:49:40
【问题描述】:
我正在使用 ACF + ACF to REST API 插件。
我有一个全局选项页面,其中包含一个链接到帖子的字段(这是一个 ACF 帖子关系字段)。
如果我导航到:/wp-json/acf/v3/options/options
响应如下所示:
{
"acf": {
"sticker_button": {
"title": "Come & visit",
"post_object": {
"ID": 311,
"post_author": "2",
"post_date": "2019-04-30 18:39:50",
"post_date_gmt": "2019-04-30 17:39:50",
"post_content": "",
"post_title": "test",
"post_excerpt": "",
"post_status": "publish",
"comment_status": "closed",
"ping_status": "closed",
"post_password": "",
"post_name": "test",
"to_ping": "",
"pinged": "",
"post_modified": "2019-04-30 18:39:50",
"post_modified_gmt": "2019-04-30 17:39:50",
"post_content_filtered": "",
"post_parent": 97,
"guid": "https://example.dev.env.example.com/?page_id=311",
"menu_order": 0,
"post_type": "page",
"post_mime_type": "",
"comment_count": "0",
"filter": "raw"
}
}
}
}
因为我正在使用 SPA 来使用这些数据,所以我不想发出另一个 API 请求只是为了获取此帖子的永久链接/链接。
有没有办法在上述帖子的回复中显示永久链接以及post_object?
仅仅使用post_name 手动建立链接是不够的,因为它可能是另一个的子页面。我在运行时需要实际的永久链接,post_name 不受页面层次结构的影响。
非常感谢您的帮助。
【问题讨论】:
标签: php json wordpress api advanced-custom-fields