acf.json

If you're using ACF Pro, this file is designed to register options pages. You should (probably) use ACF's GUI to register field groups and fields.

Here's an example of how you can define simple options pages and their hierarchy.

Example Structure

{
	"version" : "1.0.0",
	"option_pages" : {
		"example-options" : {},
		"example-theme-options" : {
			"page_title" : "Theme",
			"parent_slug" : "example-options"
		},
		"example-advanced-options" : {
			"page_title" : "Advanced",
			"parent_slug" : "example-options"
		}
	}
}

Adding ACF Field Groups and Fields

In addition to registering options pages, you can also define ACF field groups and fields directly in the acf.json file. Here's a simple example of how to add a text field to an ACF field group.

Example Structure

{
	"version": "1.0.0",
	"option_pages": {
		"example-options": {
			"field_groups": {
				"general_settings": {
					"fields": [
						{
							"label": "Site Title",
							"name": "site_title",
							"key": "site_title",
							"type": "text",
							"required": true,
							"default_value": "My Website",
							"placeholder": "Enter your site title"
						}
					]
				}
			}
		}
	}
}

Last updated