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.

181 stars

Best use case

acf-block-registration is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using acf-block-registration should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/acf-block-registration/SKILL.md --create-dirs "https://raw.githubusercontent.com/majiayu000/claude-skill-registry/main/skills/data/acf-block-registration/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/acf-block-registration/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How acf-block-registration Compares

Feature / Agentacf-block-registrationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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

| Aspect | ACF Block | Native 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 Version** | 2 | 3 |
| **Attributes** | Defined in ACF field groups | Defined in `block.json` |
| **Data access** | `get_field()` | `$attributes` array |
| **Render property** | `acf.renderTemplate` | `render` |
| **Editor experience** | ACF field forms | Custom React components |
| **Best for** | Content-heavy blocks, rapid prototyping | Complex 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](../block-scaffolds/SKILL.md):

| File | Template | Purpose |
|------|----------|---------|
| `block.json` | [block-json-acf.json](../block-scaffolds/references/block-json-acf.json) | ACF block metadata |
| `render.php` | [render-acf.php](../block-scaffolds/references/render-acf.php) | Render template |
| `helpers.php` | [helpers-acf.php](../block-scaffolds/references/helpers-acf.php) | Helper functions |
| Field group | [field-group-scaffold.json](../block-scaffolds/references/field-group-scaffold.json) | ACF field group |

### Full Examples

| Example | Purpose |
|---------|---------|
| [render-faq-example.php](../block-scaffolds/references/render-faq-example.php) | Complete FAQ render with JSON-LD |
| [helpers-faq-example.php](../block-scaffolds/references/helpers-faq-example.php) | Complete FAQ helpers |
| [block-registration.php](../block-scaffolds/references/block-registration.php) | PHP registration function |
| [acf-json-sync.php](../block-scaffolds/references/acf-json-sync.php) | ACF local JSON config |

---

## block.json Key Properties (ACF)

| Property | Required | Description |
|----------|----------|-------------|
| `$schema` | Yes | `https://advancedcustomfields.com/schemas/json/main/block.json` |
| `name` | Yes | Format: `acf/{block-name}` |
| `acf.mode` | Yes | `preview`, `edit`, or `auto` |
| `acf.renderTemplate` | Yes | Path to render PHP file |
| `style` | Optional | `file:./style.css` |

### ACF Mode Options

| Mode | Description |
|------|-------------|
| `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:

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

### Title Conventions

| Type | Title Format | Example |
|------|--------------|---------|
| 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

| Guideline | Description |
|-----------|-------------|
| `declare(strict_types=1)` | Always include at top |
| Helper file | Use `require_once __DIR__ . '/helpers.php'` |
| Data retrieval | Use helper functions, not inline `get_field()` |
| Empty state check | Return early if no data (except in editor) |
| `get_block_wrapper_attributes()` | Use for consistent wrapper |
| Editor placeholder | Show message when data is empty in editor |

### Template Variables

| Variable | Type | Description |
|----------|------|-------------|
| `$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

| Guideline | Description |
|-----------|-------------|
| `function_exists()` guard | Wrap functions in existence check |
| Default values | Always provide defaults with `?: []` or `?? ''` |
| Type hints | Use parameter and return type declarations |
| Data transformation | Normalize ACF field names to consistent keys |
| ACF guard | Check `function_exists('get_field')` |

---

## Common Field Types

### Repeater Field

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

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

### Gallery Field

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

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

### Image Field

```php
$image = get_field('image');

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

### Options Page Fields

```php
$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](../block-scaffolds/references/block-json-acf.json), 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](../block-scaffolds/references/render-acf.php)
5. **Create helpers.php**: Copy from [template](../block-scaffolds/references/helpers-acf.php)
6. **Add style.css**: See [css-standards](../css-standards/SKILL.md)
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:
```bash
.github/skills/block-scaffolds/scripts/create-block.sh acf my-block "My Block Title"
```

---

## Related Skills

- [block-scaffolds](../block-scaffolds/SKILL.md) - Copy-paste templates
- [php-standards](../php-standards/SKILL.md) - PHP conventions
- [css-standards](../css-standards/SKILL.md) - CSS conventions
- [phpunit-testing](../phpunit-testing/SKILL.md) - Testing ACF blocks
- [native-block-development](../native-block-development/SKILL.md) - Native blocks

---

## References

- [ACF Block Registration](https://www.advancedcustomfields.com/resources/blocks/)
- [ACF Block JSON Schema](https://www.advancedcustomfields.com/resources/acf-blocks-with-block-json/)
- [ACF Field Types](https://www.advancedcustomfields.com/resources/#field-types)
- [ACF Local JSON](https://www.advancedcustomfields.com/resources/local-json/)

Related Skills

ux

159
from majiayu000/claude-skill-registry

This AI agent skill provides comprehensive guidance for creating professional and insightful User Experience (UX) designs, covering user research, information architecture, interaction design, visual guidance, and usability evaluation. It aims to produce actionable, user-centered solutions that avoid generic AI aesthetics.

UX Design & StrategyClaude

thor-skills

159
from majiayu000/claude-skill-registry

An entry point and router for AI agents to manage various THOR-related cybersecurity tasks, including running scans, analyzing logs, troubleshooting, and maintenance.

SecurityClaude

ontopo

159
from majiayu000/claude-skill-registry

An AI agent skill to search for Israeli restaurants, check table availability, view menus, and retrieve booking links via the Ontopo platform, acting as an unofficial interface to its data.

General Utilities

modal-deployment

159
from majiayu000/claude-skill-registry

Run Python code in the cloud with serverless containers, GPUs, and autoscaling using Modal. This skill enables agents to generate code for deploying ML models, running batch jobs, serving APIs, and scaling compute-intensive workloads.

DevOps & Infrastructure

chrome-debug

159
from majiayu000/claude-skill-registry

This skill empowers AI agents to debug web applications and inspect browser behavior using the Chrome DevTools Protocol (CDP), offering both collaborative (headful) and automated (headless) modes.

Coding & DevelopmentClaude

grail-miner

159
from majiayu000/claude-skill-registry

This skill assists in setting up, managing, and optimizing Grail miners on Bittensor Subnet 81, handling tasks like environment configuration, R2 storage, model checkpoint management, and performance tuning.

DevOps & Infrastructure

vly-money

159
from majiayu000/claude-skill-registry

Generate crypto payment links for supported tokens and networks, manage access to X402 payment-protected content, and provide direct access to the vly.money wallet interface.

Fintech & CryptoClaude

astro

159
from majiayu000/claude-skill-registry

This skill provides essential Astro framework patterns, focusing on server-side rendering (SSR), static site generation (SSG), middleware, and TypeScript best practices. It helps AI agents implement secure authentication, manage API routes, and debug rendering behaviors within Astro projects.

Coding & Development

lets-go-rss

159
from majiayu000/claude-skill-registry

A lightweight, full-platform RSS subscription manager that aggregates content from YouTube, Vimeo, Behance, Twitter/X, and Chinese platforms like Bilibili, Weibo, and Douyin, featuring deduplication and AI smart classification.

Content & Documentation

tech-blog

159
from majiayu000/claude-skill-registry

Generates comprehensive technical blog posts, offering detailed explanations of system internals, architecture, and implementation, either through source code analysis or document-driven research.

Content & DocumentationClaude

whisper-transcribe

159
from majiayu000/claude-skill-registry

Transcribes audio and video files to text using OpenAI's Whisper CLI, enhanced with contextual grounding from local markdown files for improved accuracy.

Media Processing

advanced-skill-creator

181
from majiayu000/claude-skill-registry

Meta-skill that generates domain-specific skills using advanced reasoning techniques. PROACTIVELY activate for: (1) Create/build/make skills, (2) Generate expert panels for any domain, (3) Design evaluation frameworks, (4) Create research workflows, (5) Structure complex multi-step processes, (6) Instantiate templates with parameters. Triggers: "create a skill for", "build evaluation for", "design workflow for", "generate expert panel for", "how should I approach [complex task]", "create skill", "new skill for", "skill template", "generate skill"