askill
acf-block-registration

acf-block-registrationSafety 95Repository

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.

0 stars
1.2k downloads
Updated 1/10/2026

Package Files

Loading files...
SKILL.md

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
Schemahttps://advancedcustomfields.com/schemas/json/main/block.jsonhttps://schemas.wp.org/trunk/block.json
Name prefixacf/theme-oh-my-brand/
API Version23
AttributesDefined in ACF field groupsDefined in block.json
Data accessget_field()$attributes array
Render propertyacf.renderTemplaterender
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.jsonblock-json-acf.jsonACF block metadata
render.phprender-acf.phpRender template
helpers.phphelpers-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
$schemaYeshttps://advancedcustomfields.com/schemas/json/main/block.json
nameYesFormat: acf/{block-name}
acf.modeYespreview, edit, or auto
acf.renderTemplateYesPath to render PHP file
styleOptionalfile:./style.css

ACF Mode Options

ModeDescription
previewShows rendered block output, click to edit fields
editShows ACF field form directly
autoSwitches 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 groupsBlock: {Block Name}Block: FAQ
Options pages{Page Name} SettingsTheme Settings
Post type fields{Post Type} FieldsCompany 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
$blockarrayBlock settings (id, name, className, align)
$contentstringInner HTML (usually empty for ACF blocks)
$is_previewboolTrue when rendering in editor preview
$post_idintPost ID where block is used
$contextarrayBlock context values

Helper Function Guidelines

GuidelineDescription
function_exists() guardWrap 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

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

88/100Analyzed 2/24/2026

High-quality technical reference skill for ACF block registration in WordPress. Comprehensive content with clear tables, code examples, step-by-step instructions, and reusable templates. Well-structured with ACF vs native block comparison, file conventions, and helper guidelines. Located in .github/skills suggesting internal agent use, but content is accurate and valuable even as reference. Minor扣分 for internal-only path but overall excellent skill documentation.

95
94
85
95
92

Metadata

Licenseunknown
Version-
Updated1/10/2026
PublisherWesleySmits

Tags

apigithub