You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过ACF嵌套字段abc.a=11构建WP REST API元查询?

Got it, let's break this down for you since you're working with ACF data via an API and only have access to the endpoint (no code changes allowed):

Filtering ACF Nested Field abc.a = 11 via API Query Parameters

First, let's recall how ACF stores nested fields behind the scenes. When you have a field group like abc with sub-fields a and b, ACF doesn't store the entire abc object as a single database entry. Instead, each sub-field gets its own meta key in the format parent_field_subfield (using underscores to link the parent and child names).

Your example for filtering test=true uses a meta_query targeting the top-level test field. For the nested abc.a field, we just need to adjust the key to match ACF's stored meta key for that sub-field.

The Exact Query String

Here's the query you need to append to your API endpoint:

meta_query[0][key]=abc_a&meta_query[0][compare]==&meta_query[0][value]=11

If your API requires HTML-encoded ampersands (like your test example used & instead of &), use this version instead:

meta_query[0][key]=abc_a&meta_query[0][compare]==&meta_query[0][value]=11

Quick Notes:

  • We use compare= here because abc.a is an exact string value ("11")—this is more precise than like (which your test example used for a boolean value stored as 1). If you ever need partial matches, you can swap back to compare=like.
  • This works because ACF maps the nested abc.a field to the meta key abc_a in the WordPress database, so targeting that key directly will filter results where abc.a equals "11".

内容的提问来源于stack exchange,提问作者NotABot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:37:25