ACF Composer (by Log1x) excels at defining ACF Blocks and Field Groups in a structured, object-oriented way using PHP classes.
While you could use ACF Composer to register block patterns, it doesnβt offer a significant advantage over your current method via setup.php β especially when it comes to layout-based patterns.
You're already following a common and valid method:
- Defining patterns as PHP files containing block markup
e.g.,faq-pattern.php,modern-pricing-table.php - Reading these files and their metadata in
setup.php - Registering them using the standard
register_block_pattern()function - Styling them in
app.cssandeditor.css
This setup works well for layout-based, reusable block patterns.
If you wanted to centralize pattern registration in ACF Composer, you would typically:
- Create a dedicated Composer class for each pattern, or use a service provider.
- Inside that class/provider:
- Read the pattern file content (like your
get_processed_pattern_content()insetup.php). - Register it using
register_block_pattern().
- Read the pattern file content (like your
- Remove pattern logic from
setup.php.
π§ This approach centralizes logic, which is nice for consistency if you're already deep into ACF Composer.
However, it doesn't change how the patterns work or render β it's more about structure.
- Reusable layouts built with existing core/custom blocks
- Content is editable within the editor
- No ACF fields involved
- Great for static layouts like:
- Pricing tables
- FAQs
- Hero sections
- Custom block types with specific ACF fields
- Rendered using Blade templates
- Perfect for components needing structured data, such as:
- Testimonial blocks (name, quote, image)
- Team member blocks
- Accordions with dynamic content
Your current
faq-pattern.phpandmodern-pricing-table.phpare patterns, not ACF Blocks.
- Stick with your current method in
setup.phpfor block patterns β it's efficient and fully valid. - Use ACF Composer when you need to build custom blocks with field input, rendering logic, and better reusability.
- You're free to mix both methods:
- Use
setup.phpfor layout patterns - Use ACF Composer for field-driven ACF Blocks
- Use