WordPress systems / Case 02
Reusable WordPress location templates that editors can update through ACF
Repeated location pages needed one maintainable layout while non-technical editors still controlled local copy, statistics, office details, forms, and optional sections.
Plain-English summary
What this solved for the business or user
Instead of asking an editor to duplicate a page builder layout for every city, the page structure stays in the theme and the editable business content lives in clearly named fields. Updating an office, headline, statistic, or section does not require touching PHP or recreating spacing by hand.
01 / Real situation
What was happening
The site had many location pages with the same broad structure but different city names, office details, localized copy, forms, statistics, and optional blocks. Copying full page markup for every location would make small design fixes expensive because the same change would have to be repeated across many pages.
02 / Constraint
Why the obvious solution was not enough
The template had to stay flexible enough for real content differences without giving editors so much layout freedom that pages drifted apart. Existing content also needed sensible fallbacks so a missing repeater row or legacy value did not leave a broken section.
03 / Implementation
How the solution works
- Keep structural markup, responsive behavior, and accessibility rules in one PHP template instead of duplicating them in each page.
- Create grouped ACF fields for business content such as hero copy, statistics, office labels, addresses, form settings, and reusable section content.
- Add enable/disable toggles for optional sections so an editor can remove a block without deleting its saved content or editing template code.
- Support simple location tokens in text fields so one content pattern can safely render the relevant city or location name.
- Normalize rich-text output before rendering. When a field contains plain copy instead of paragraph, list, or heading markup, apply WordPress formatting instead of assuming the editor entered HTML.
- Provide fallback values for required content and legacy fields so older pages keep rendering while the content model evolves.
- Keep SEO and presentation fallbacks close to the content model so the same location value is used consistently in visible copy and metadata.
$title = get_field('location_section_title', $page_id) ?: 'Serving {{location}}';
$title = str_replace('{{location}}', $location_name, $title);
$content = get_field('location_intro', $page_id) ?: $fallback_intro;
if (!preg_match('/<(p|ul|ol|h[1-6])\b/i', $content)) {
$content = wpautop($content);
}
echo wp_kses_post($content);04 / Release checks
What should be verified before shipping
- Create a new location using only the required fields and confirm every section has a safe default state.
- Disable and re-enable optional sections and confirm saved content is preserved.
- Test tokens in headings, form titles, office labels, and other supported fields.
- Verify plain text, lists, and editor-produced HTML all render with usable spacing.
- Change the shared template once and confirm the improvement reaches multiple location pages without manual duplication.
- Test desktop, tablet, and mobile because a reusable content model is only useful if the shared layout remains responsive.
05 / Result
What changed
Content updates became safer for non-technical editors while layout fixes stayed centralized for developers. New location pages could reuse the same tested structure instead of starting from a copied builder layout.
Reusable lessonThe best editor experience is not unlimited layout control. Give editors control over business content and intentional options, while keeping repeated layout rules in a reusable component or template.
References
