ダブルクリックで英日反転
Applied Sciences · Engineering
WordPress ACF and custom fields — why they don't appear in the REST API
ACF custom fields are saved as post_meta, but the REST API only outputs explicitly registered items — so they are hidden by default. Three fixes exist, and the cleanest requires just a toggle.
What ACF custom fields are
- ACF (Advanced Custom Fields) is the standard plugin for adding custom input fields to WordPress posts.
- Fields like "price", "rating", or "person in charge" extend the built-in title/body/category set.
- Field values are stored as WordPress post_meta (post metadata).
The REST API and why fields go missing
- The REST API (/wp-json/wp/v2/posts) returns post data as JSON over HTTP.
- Only explicitly registered items appear in the response — post_meta is excluded by default.
- Hitting the endpoint returns title/content/excerpt but not ACF field data.
Three solutions
- 1. Enable "Show in REST API" in the ACF field group settings (ACF ≥ 5.11) — adds an acf key to the response.
- 2. Call register_rest_field() in PHP (functions.php or a plugin) for fine-grained control.
- 3. Install the "ACF to REST API" plugin — quick option for older ACF versions, but adds a dependency.
Relevance to headless WordPress
- Headless WordPress uses WP only as a CMS; a separate frontend (e.g., Next.js) fetches data via the REST API or WPGraphQL.
- Heavy ACF usage in a headless setup makes this missing-field problem almost inevitable.
- Always check "Show in REST API" when creating a field group in a headless project.
→ ACF fields are hidden from the REST API by design — on ACF 5.11+, one toggle in the field group settings fixes it.
Applied Sciences · Engineering
WordPress ACF カスタムフィールドが REST API に出ない理由と3つの解決策
ACF(Advanced Custom Fields=カスタム入力欄を自由に追加できるプラグイン)のフィールドは post_meta として保存されるが、REST API はデフォルトで明示登録済みの項目しか返さない。
ACF カスタムフィールドとは
- ACF は WordPress に独自の入力欄(カスタムフィールド)を追加する定番プラグイン。
- 「価格」「評価(星の数)」「担当者」など、標準セットにない項目を自由に定義できる。
- 入力値は WordPress の post_meta(投稿メタデータ)として DB に保存される。
REST API とフィールドが消える理由
- REST API(/wp-json/wp/v2/posts)は投稿データを JSON で返す WordPress 標準インターフェース。
- レスポンスに含まれるのは「明示的に登録された項目」のみ — post_meta はデフォルト除外。
- 結果、title/content/excerpt は返るが ACF フィールドの値が JSON に現れない。
3 つの解決策
- ① ACF のフィールドグループ設定で「REST API に表示」をオン(ACF 5.11 以降)— acf キーで値が返る。
- ② PHP で register_rest_field() を呼び出し、任意フィールドを REST API に手動登録。
- ③「ACF to REST API」プラグインを導入 — 旧バージョン向けだが依存が増える。
ヘッドレス WordPress との関係
- ヘッドレス構成=WordPress をデータ管理専用CMS にし、表示は Next.js 等の別フロントエンドが担う設計。
- フロントエンドは REST API または WPGraphQL(GraphQL でデータ取得するプラグイン)でデータを受け取る。
- ACF を多用するほどこの「表示されない」問題に必ず直面するため、フィールドグループ作成時に設定を確認する。
→ ACF フィールドが REST API に出ないのは仕様。ACF 5.11 以降はフィールドグループの「REST API に表示」を ON にするだけで解決する。
Applied Sciences · Engineering
WordPress ACF and custom fields — why they don't appear in the REST API
ACF custom fields are saved as post_meta, but the REST API only outputs explicitly registered items — so they are hidden by default. Three fixes exist, and the cleanest requires just a toggle.
What ACF custom fields are
- ACF (Advanced Custom Fields) is the standard plugin for adding custom input fields to WordPress posts.
- Fields like "price", "rating", or "person in charge" extend the built-in title/body/category set.
- Field values are stored as WordPress post_meta (post metadata).
The REST API and why fields go missing
- The REST API (/wp-json/wp/v2/posts) returns post data as JSON over HTTP.
- Only explicitly registered items appear in the response — post_meta is excluded by default.
- Hitting the endpoint returns title/content/excerpt but not ACF field data.
Three solutions
- 1. Enable "Show in REST API" in the ACF field group settings (ACF ≥ 5.11) — adds an acf key to the response.
- 2. Call register_rest_field() in PHP (functions.php or a plugin) for fine-grained control.
- 3. Install the "ACF to REST API" plugin — quick option for older ACF versions, but adds a dependency.
Relevance to headless WordPress
- Headless WordPress uses WP only as a CMS; a separate frontend (e.g., Next.js) fetches data via the REST API or WPGraphQL.
- Heavy ACF usage in a headless setup makes this missing-field problem almost inevitable.
- Always check "Show in REST API" when creating a field group in a headless project.
→ ACF fields are hidden from the REST API by design — on ACF 5.11+, one toggle in the field group settings fixes it.
Applied Sciences · Engineering
WordPress ACF カスタムフィールドが REST API に出ない理由と3つの解決策
ACF(Advanced Custom Fields=カスタム入力欄を自由に追加できるプラグイン)のフィールドは post_meta として保存されるが、REST API はデフォルトで明示登録済みの項目しか返さない。
ACF カスタムフィールドとは
- ACF は WordPress に独自の入力欄(カスタムフィールド)を追加する定番プラグイン。
- 「価格」「評価(星の数)」「担当者」など、標準セットにない項目を自由に定義できる。
- 入力値は WordPress の post_meta(投稿メタデータ)として DB に保存される。
REST API とフィールドが消える理由
- REST API(/wp-json/wp/v2/posts)は投稿データを JSON で返す WordPress 標準インターフェース。
- レスポンスに含まれるのは「明示的に登録された項目」のみ — post_meta はデフォルト除外。
- 結果、title/content/excerpt は返るが ACF フィールドの値が JSON に現れない。
3 つの解決策
- ① ACF のフィールドグループ設定で「REST API に表示」をオン(ACF 5.11 以降)— acf キーで値が返る。
- ② PHP で register_rest_field() を呼び出し、任意フィールドを REST API に手動登録。
- ③「ACF to REST API」プラグインを導入 — 旧バージョン向けだが依存が増える。
ヘッドレス WordPress との関係
- ヘッドレス構成=WordPress をデータ管理専用CMS にし、表示は Next.js 等の別フロントエンドが担う設計。
- フロントエンドは REST API または WPGraphQL(GraphQL でデータ取得するプラグイン)でデータを受け取る。
- ACF を多用するほどこの「表示されない」問題に必ず直面するため、フィールドグループ作成時に設定を確認する。
→ ACF フィールドが REST API に出ないのは仕様。ACF 5.11 以降はフィールドグループの「REST API に表示」を ON にするだけで解決する。
Related notes
- Agentic Commerce — ACP and Visibility into Being 'Bought by AI'
- AI Search Evaluation: The 12 Metrics — Gateway
- AI Search Evaluation ①Citation Rate — How Many URLs Are Pulled In Per Answer
- AI Search Evaluation ②Source Diversity — How Unskewed the Cited Sources Are
- AI Search Evaluation ③Accuracy Score — How Often It Answers Factual Questions Correctly
- AI Search Evaluation ④Answer Length — How Many Characters It Returns to the User on Average