WordPress
ACF Content Models That Stay Maintainable in Practice
ACF content models stay maintainable when field groups map to one content type, flexible content layouts are few and named by intent, and the same fields feed both the rendered page and its structured data. I'm Saif Al Jahan of webdev-saif.com; in my WordPress builds I register fields in code, read them through get_field and generate JSON-LD from those values so the markup cannot drift from what visitors see.
Design field groups around one content type
A maintainable ACF content model starts with field groups that each describe one thing. I keep a group for page-level settings, one for the service or project entity, and separate groups for repeated structures such as team members or case-study metrics. Each group gets a clear label, a machine-safe name with no spaces, and a location rule that is specific enough that an editor never sees fields that do not apply to the current screen. When a field would be useful in two places, I decide whether it is truly shared — in which case it belongs in a single group with a narrow location rule — or whether two similarly named fields are clearer than one overloaded one.
- One group per content type, named with lowercase letters, numbers and underscores
- Location rules tied to a specific post type, template or taxonomy
- Shared fields in one group, never duplicated with slightly different names
- Required only where the value is genuinely needed on the page
Register fields in code, not only in the admin
ACF stores field groups in the database by default, which makes them easy to edit in the admin and hard to review in version control. I register field groups in PHP with acf_add_local_field_group in a small plugin or theme module, so the model is diffable, deployable and identical across local, staging and production. The admin screen then becomes a read-only view of the schema. For teams that prefer the UI, ACF JSON sync is the next best option: save field groups to acf-json in the theme and commit them, so a change is a pull request rather than a click on a live server.
Flexible content with disciplined layouts
Flexible content is the fastest way to turn a clean model into a mess. I treat each layout as a named, documented pattern — hero, feature grid, testimonial, FAQ — and cap the number of layouts on any one template. Every layout has a fixed set of subfields with sensible defaults, and I avoid nesting flexible content inside flexible content because the render logic becomes impossible to reason about. The template that loops through have_rows must be the single source of truth for markup: if a layout needs a new class or an accessibility attribute, it changes in one PHP file, not in each editor's content.
- Six to eight named layouts per template, not twenty near-duplicates
- No nested flexible content; use a repeater inside a layout instead
- Each layout rendered by one dedicated template partial
- Defaults set in PHP so a new row is never blank
Reading fields predictably with get_field and get_sub_field
Most ACF bugs are not schema bugs; they are inconsistent reads. I call get_field with an explicit post ID inside loops and hooks, never relying on the global post, and I pass false as the third argument when I need the raw value rather than formatted output. Repeater and flexible content rows are read through have_rows and get_sub_field inside the loop, then mapped into a plain PHP array before anything is printed. That array is the boundary between content and presentation: once the data is flat, the template can focus on markup and the same array can be handed to a schema builder.
- get_field($key, $post_id) everywhere outside the main loop
- get_field($key, $post_id, false) for raw values used in JSON-LD
- have_rows and get_sub_field only inside the row loop
- One mapping function that turns rows into a flat array
Feeding structured data from the same fields
This is where the content model pays for itself. I build a single PHP function that takes the flat array from the previous step and returns a JSON-LD graph, then echo it in wp_head with wp_json_encode and JSON_UNESCAPED_SLASHES. Because the visible template and the schema function read the same array, a price, a date or a FAQ answer cannot appear on the page while the markup says something else. For a service page that means Service and FAQPage nodes; for a project it means CreativeWork with the same headline and description the visitor reads. Schema becomes a projection of the model, not a second content entry job.
- wp_json_encode with JSON_UNESCAPED_SLASHES and JSON_UNESCAPED_UNICODE
- FAQPage answers pulled from the same repeater rows the page renders
- BreadcrumbList built from get_the_terms or the page hierarchy
- One filter hook so child themes can add nodes without editing core
Keeping the model maintainable as the site grows
In my builds at webdev-saif.com, maintainability is mostly about naming and limits. I use a single underscore-separated prefix for every field name, document each layout in a short PHP comment, and keep a small fixture post with example content for each content type so a new developer can see the intended shape. When a field changes, I write a one-off migration that maps old values to the new key rather than asking editors to re-enter data. I also resist the temptation to add a field for every hypothetical case; if no template reads it today, it does not ship. Fewer fields mean fewer decisions for the editor and fewer branches in the renderer.
Common mistakes and trade-offs
The biggest mistake is letting the page builder own the content model. Builder widgets wrap markup in extra divs and often duplicate the same field in several places, which breaks both heading order and schema consistency. The second is putting too much logic in the template: once a single file handles six layouts, five conditionals and three schema types, nobody wants to change it. I split rendering from data mapping and keep schema generation in its own function. The trade-off is more files and a small amount of upfront structure, but the result is a model an editor can use safely and a developer can change in one place.
Frequently asked questions
What is an ACF content model?
An ACF content model is the set of field groups, location rules and field types that define what content a WordPress page or custom post type can hold. It is the schema behind the editing screen. A good model maps one group to one content type, uses predictable field names, and is stored in code or ACF JSON so it can be reviewed and deployed.
Should I register ACF fields in PHP or in the admin?
Register them in PHP with acf_add_local_field_group when you control the codebase, because the schema becomes version-controlled and identical on every environment. If your editors need to change fields themselves, use ACF JSON sync instead: groups are edited in the admin, saved to the acf-json directory, and committed. What you should avoid is fields that exist only in the production database.
How many flexible content layouts is too many?
More than about eight layouts on one template is usually a sign that the template should be split into two content types. Each layout adds a branch to the renderer and a decision for the editor. I keep layouts named by purpose, reuse repeaters inside them, and never nest flexible content inside flexible content. If two layouts differ only by an image position, they should be one layout with a select field.
How do I generate JSON-LD schema from ACF fields?
Map the field values into one plain PHP array, then pass that array to a function that returns a schema.org graph. Echo it in wp_head with wp_json_encode. Because the visible template and the schema function read the same array, the FAQ answers, dates and prices in the markup always match the page. I never maintain a separate set of values just for structured data.
Can I use ACF with Elementor or another page builder?
Yes, with a boundary. I use ACF for the structured fields and let the builder handle layout, then inject the ACF values through dynamic tags or a short hook rather than duplicating the content in the builder. The risk is markup: builders add wrapper elements that can disturb heading order and schema alignment. On the sites I build at webdev-saif.com, the field group stays the single source of truth.