Short answer
Give each distinct page its own template file and its own ACF field group, shown only for that template, and give post families one shared template. Owners then edit labelled fields, the layout stays in code, and Local JSON keeps the fields in version control.
In this article
Key points
- Layout belongs in code and content belongs in labelled fields, so owners cannot break the design.
- Use page-{slug}.php for fixed pages and a named template or custom post type template for reusable layouts.
- Design each field group with narrow field types, instructions, limits and a location rule.
- Save field groups with ACF Local JSON and commit them with the template changes.
- Escape every field on output with the matching esc_ function.
Most client sites break the same way. The site launches clean. A few months later the owner edits the home page, adds a block, pastes a long heading, drags a column, and the layout no longer matches the design. Nobody did anything wrong. The tools allowed it.
My fix is a rule that is easy to say and takes discipline to follow: every distinct page gets its own template and its own set of fields. The owner edits text, images and links in plain, labelled boxes. The layout lives in code and does not move. This post explains how to build it with WordPress templates and Advanced Custom Fields (ACF), and what to check before you hand the site over.
The problem with free-form editing
A page builder or a heavy block editor gives the editor control over layout. That sounds like a gift, and for a one-person blog it can be. For a business site with a set design, it is a risk. The more layout choices an editor has, the more ways there are to drift away from the design, the speed budget and the markup that search engines read.
I wrote about my reasons in why I stopped using page builders for client sites. The short version: markup you do not control is markup you cannot fix quickly. The template-and-fields approach keeps the design decisions with the developer and the content decisions with the owner.
The result for the owner is better, not worse. They open a page, see a short form with clear labels, type, save. They cannot break the layout because the layout is not in the form.
The rule: one page, one template, one field group
Here is the rule in full.
- Every distinct page, such as Home, About, Contact or a service landing page, has its own page template file.
- Every one of those templates has its own ACF field group, shown only when that template is in use.
- Families of pages, such as blog posts, locations, services or products, share one template per type, with one field group per type.
- The theme controls how the site looks. A plugin controls behaviour such as forms or schema. Content lives in fields.
- Everything is saved in version control, and every release has a version number and a changelog entry.
This sounds like a lot of files. In practice it is clean. A site with ten unique pages has ten templates and ten field groups, each small and easy to read. Compare that with one giant page layout that tries to serve every case with switches and conditions.
How WordPress picks a template
You do not need to memorize the hierarchy, but you should know the parts you will use. According to the WordPress template hierarchy, a page uses the first match in this order: the custom template assigned to that page, then page-{slug}.php, then page-{ID}.php, then page.php, then singular.php, then index.php. For single posts and custom post types, it looks for single-{post-type}-{slug}.php, then single-{post-type}.php, then single.php, and so on.
| Approach | How it works | When I use it |
|---|---|---|
| Custom template with a Template Name header | A comment at the top of the file names it, and the editor picks it in the page’s Template setting | Pages that follow a layout but may be reused or created by the owner |
page-{slug}.php |
WordPress applies it to the page with that slug automatically | Unique pages such as Home or Contact, where no choice should exist |
single-{post-type}.php |
One template for every item of a custom post type | Locations, services, case studies and products |
Two practical details from the page template documentation save time. A global template file should not start with page-, because WordPress treats that prefix as a single-page template. And specialized templates such as page-{slug}.php must sit in the theme’s root folder, while global templates can sit in the root or one first-level subfolder like page-templates/.
For fixed pages I prefer the slug-based file. The owner cannot assign the wrong template, because there is no choice to make. For reusable layouts I use a named template so a new page can pick it.
Build a field group the owner cannot misuse
A field group is the form the owner sees. Good forms prevent mistakes, so I design them with care.
- Show it only where it belongs. In ACF, set the location rule so the group appears only for the matching page template or post type. An About page should not show Contact fields.
- Use the narrowest field type. A button needs a text label and a URL, not a rich editor. A headline is a single-line text field. Use a rich editor only for body copy that really needs formatting.
- Write instructions on every field. Say what it is for and where it appears. “Headline at the top of the page, about 60 characters” beats “Title”.
- Set limits. Use character limits, required flags and image size notes so the layout does not receive a 40-word headline.
- Group related fields. Use a clear order that follows the page from top to bottom, so the form reads like the page.
- Prefer repeating rows over free layouts. If the page has a list of benefits, give it a repeating group of three fields: icon, title, text. Do not give the owner a blank canvas.
Search fields should be easy to find too. I keep the title and description handling in the SEO plugin, as I describe in my Rank Math setup for new WordPress sites, and I do not duplicate them in custom fields. One place for each job.
If the owner can break it, the form is wrong. Fix the form.
Own-ur-Rehman Sheikh
Post families share one template
Not every page is unique. A blog with 200 posts does not need 200 templates. A site with 30 locations does not need 30 either. For these families, one template and one field group serve all items.
The design question is what belongs in the shared template and what belongs in the item’s own fields. I use a simple split:
- Same for every item: layout, section order, styles and the schema type.
- Different for each item: text, images, facts and links, stored in fields.
- Optional sections: controlled by a field being filled. If a field is empty, its section does not print, so there are no blank boxes on the page.
This is also what makes quality control possible. When every location page comes from the same template, you can check one template and know all of them are right. If the layout needs a change, you change it once.
Native fields first
Before I add a custom field, I check whether WordPress already has a place for the content. The page title, the featured image, the excerpt and the main content area all exist for a reason. I use them where they fit and add fields only for the extra pieces the design needs. Fewer custom fields means a shorter form, fewer things to maintain and a simpler move if the site changes hands.
The same thinking applies to categories and tags. If a custom post type needs a label such as a service area or a product type, a taxonomy is usually better than a text field, because it can be filtered, listed and linked.
Keep field groups in version control
Field groups that exist only in a database are fragile. They differ between staging and live, they cannot be reviewed, and they vanish if the database is restored from the wrong backup. ACF Local JSON solves this.
With Local JSON turned on, ACF saves field groups as JSON files in an acf-json folder in your theme. The ACF documentation lists the benefits: teams can share field settings through Git, and ACF loads settings from files, which reduces database calls on page load. When a JSON file is newer than the database record, ACF shows a Sync option so you can import the change.
Here is the workflow I follow.
- Edit field groups on a development copy of the site.
- ACF writes the changes to the
acf-jsonfolder. - Commit the files with the template changes, in the same branch.
- Bump the theme version and add a line to the changelog.
- Deploy, then use the Sync option on the live site if it shows pending changes.
Two practical notes from the ACF page. The server must be able to write to the folder, and adding an empty index.php file to it helps prevent directory listing. Never edit files on the live server by hand. A fix made live and not committed will be overwritten at the next deploy, or worse, it will be lost.
Escape every field on output
Fields give owners control over content, which means templates print content that someone typed. That content must be escaped when it is output. The WordPress developer handbook calls the principle “escape late”: apply escaping as close to the point of output as you can.
The functions to know are these:
esc_html()for text inside an HTML element.esc_attr()for values printed into attributes.esc_url()for every URL, includinghrefandsrcvalues.wp_kses_post()for content that should keep safe formatting, such as the output of a rich text field.
In a template this looks like wrapping the field call, for example esc_html( get_field( 'headline' ) ). It is one more step for each field, and it stops a whole class of security problems. It also protects the layout, because stray markup in a headline is stripped instead of printed.
A handover checklist
Before I give a site to an owner, I run through this list.
- Every unique page has its own template and its own field group, visible only where it belongs.
- Every field has a label and instructions, and limits where the layout needs them.
- Empty optional fields hide their sections cleanly.
- All output is escaped.
- The field groups are saved in the
acf-jsonfolder and committed. - I have asked the owner to edit each page, and watched for anything that confuses them.
That last step finds problems fast. If the owner hesitates at a field, the label is wrong. Fix it, and the site gets easier to edit for every person who follows. For the wider view of how structure affects search, Rank Ray’s guide to web design and SEO architecture is a good next read.
FAQ
Does every page really need its own template?
Every distinct page does, such as Home, About or Contact. Families of similar pages, such as blog posts or locations, share one template per type.
What is the difference between a page-slug template and a named template?
A page-{slug}.php file applies automatically to the page with that slug. A named template uses a Template Name header and the editor picks it in the page settings.
What is ACF Local JSON?
It saves field groups as JSON files in an acf-json folder in your theme. That lets you keep them in Git and reduces database calls when ACF loads field settings.
Do I need to escape ACF fields?
Yes. WordPress advises escaping late, at the point of output. Use esc_html for text, esc_attr for attributes, esc_url for URLs and wp_kses_post for safe formatted content.
Where should SEO titles and descriptions live?
Keep them in your SEO plugin and do not duplicate them in custom fields. One place for each job keeps the editing screen simple.




