Claude-skill-registry acf-block-registration

Guide for creating ACF PRO blocks with field groups in Oh My Brand! FSE theme. Use this when registering ACF blocks, creating field groups, or working with ACF-specific render templates.

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/acf-block-registration" ~/.claude/skills/majiayu000-claude-skill-registry-acf-block-registration && rm -rf "$T"
manifest: skills/data/acf-block-registration/SKILL.md
source content

ACF Block Registration

Creating ACF PRO blocks with custom field groups for the Oh My Brand! FSE theme.


When to Use

  • Creating blocks that use ACF field groups for content entry
  • Building blocks with repeater fields, galleries, or complex field layouts
  • Leveraging ACF PRO features (repeaters, flexible content, clone fields)
  • Rapid block prototyping with ACF's visual field editor

ACF vs Native Blocks

AspectACF BlockNative Block
Schema
https://advancedcustomfields.com/schemas/json/main/block.json
https://schemas.wp.org/trunk/block.json
Name prefix
acf/
theme-oh-my-brand/
API Version23
AttributesDefined in ACF field groupsDefined in
block.json
Data access
get_field()
$attributes
array
Render property
acf.renderTemplate
render
Editor experienceACF field formsCustom React components
Best forContent-heavy blocks, rapid prototypingComplex interactivity, custom UI

Block File Structure

ACF blocks live in

blocks/acf-{block-name}/
:

blocks/acf-faq/
├── block.json          # ACF block metadata (ACF schema)
├── render.php          # Render template (referenced in block.json)
├── helpers.php         # Block-specific helper functions
├── style.css           # Frontend styles (auto-enqueued)
└── editor.css          # Editor-only styles (optional)

Field groups are stored separately in

acf-json/
.


File Templates

Use templates from block-scaffolds:

FileTemplatePurpose
block.json
block-json-acf.jsonACF block metadata
render.php
render-acf.phpRender template
helpers.php
helpers-acf.phpHelper functions
Field groupfield-group-scaffold.jsonACF field group

Full Examples

ExamplePurpose
render-faq-example.phpComplete FAQ render with JSON-LD
helpers-faq-example.phpComplete FAQ helpers
block-registration.phpPHP registration function
acf-json-sync.phpACF local JSON config

block.json Key Properties (ACF)

PropertyRequiredDescription
$schema
Yes
https://advancedcustomfields.com/schemas/json/main/block.json
name
YesFormat:
acf/{block-name}
acf.mode
Yes
preview
,
edit
, or
auto
acf.renderTemplate
YesPath to render PHP file
style
Optional
file:./style.css

ACF Mode Options

ModeDescription
preview
Shows rendered block output, click to edit fields
edit
Shows ACF field form directly
auto
Switches between preview and edit automatically

Field Group Structure

Field groups connect to blocks via location rules:

"location": [
    [
        {
            "param": "block",
            "operator": "==",
            "value": "acf/faq"
        }
    ]
]

Title Conventions

TypeTitle FormatExample
Block field groups
Block: {Block Name}
Block: FAQ
Options pages
{Page Name} Settings
Theme Settings
Post type fields
{Post Type} Fields
Company Fields

Render Template Guidelines

GuidelineDescription
declare(strict_types=1)
Always include at top
Helper fileUse
require_once __DIR__ . '/helpers.php'
Data retrievalUse helper functions, not inline
get_field()
Empty state checkReturn early if no data (except in editor)
get_block_wrapper_attributes()
Use for consistent wrapper
Editor placeholderShow message when data is empty in editor

Template Variables

VariableTypeDescription
$block
array
Block settings (id, name, className, align)
$content
string
Inner HTML (usually empty for ACF blocks)
$is_preview
bool
True when rendering in editor preview
$post_id
int
Post ID where block is used
$context
array
Block context values

Helper Function Guidelines

GuidelineDescription
function_exists()
guard
Wrap functions in existence check
Default valuesAlways provide defaults with
?: []
or
?? ''
Type hintsUse parameter and return type declarations
Data transformationNormalize ACF field names to consistent keys
ACF guardCheck
function_exists('get_field')

Common Field Types

Repeater Field

$items = get_field('repeater_field_name') ?: [];

foreach ($items as $item) {
    $sub_value = $item['sub_field_name'] ?? '';
}

Gallery Field

$images = get_field('gallery') ?: [];

foreach ($images as $image) {
    $url = $image['url'] ?? '';
    $alt = $image['alt'] ?? '';
}

Image Field

$image = get_field('image');

if ($image) {
    $url = $image['url'];
    $alt = $image['alt'];
}

Options Page Fields

$logo = get_field('site_logo', 'option');

Step-by-Step Creation

  1. Create directory:
    mkdir -p blocks/acf-my-block
  2. Add block.json: Copy from template, use ACF schema
  3. Create field group: In WP Admin > ACF > Field Groups
    • Title:
      Block: {Block Name}
    • Location: Block equals
      acf/{block-name}
  4. Create render.php: Copy from template
  5. Create helpers.php: Copy from template
  6. Add style.css: See css-standards
  7. Register block: Add to
    $acf_blocks
    array in
    functions.php
  8. Verify: Block appears in editor and renders correctly

Or use the scaffolding script:

.github/skills/block-scaffolds/scripts/create-block.sh acf my-block "My Block Title"

Related Skills


References