04 — Technical case study
Healthcare
clinic platform.
Custom clinic theme with 16 service-specific templates and a self-bootstrapping system — activate the theme and every page is created automatically with its template pre-assigned. Zero clicks in wp-admin.
- Role
- Engineer · Client work
- Year
- 2025
- Status
- Live · production
- Scope
- Theme · Templates · Bootstrapping
- Stack
- WordPress · PHP · Tailwind
- Sector
- Healthcare · Clinic · NDA
01
Pattern.
Theme-as-installer
The theme is the installer. Activate it = full site, production-ready, without a single click in wp-admin.
- 01
Self-bootstrapping pages
When the theme activates,
bernad_create_*_page()runs on theafter_setup_themehook. Each function checks whether the page already exists (get_page_by_path); if not, it creates it withwp_insert_postand assigns the template via the_wp_page_templatemeta. Zero manual steps — install the theme and the site is complete. - 02
Service-specific templates
12 dedicated templates, one per medical specialty:
page-implantologia.php,page-endodoncia.php,page-ortodoncia.php,page-cirugia-oral.php, etc. Each with its own copy, hero, FAQs and schema. Maintainable through clear separation of concerns. - 03
Institutional pages module
4 extra templates for "facilities", "technology", "team", "about" — same auto-creation cycle with their assigned templates. Information architecture codified in the theme, not in wp-admin.
- 04
DRY page-creation helper
Reusable function
bernad_create_page_if_not_exists($slug, $title, $template)abstracts the pattern. Service and info functions iterate over config arrays and delegate to the helper. Adding a new specialty = one line in the array. - 05
Permalinks auto-flush
When pages are created/assigned, a deferred
flush_rewrite_rulesis scheduled to guarantee clean URLs (/implantologia/,/endodoncia/) without requiring the admin to touch Settings → Permalinks.
02
Signal.
The bootstrapping pattern
functions.php · service pages bootstrap
function bernad_create_page_if_not_exists(
$slug, $title, $template_name
) {
if (get_page_by_path($slug)) return;
$page_id = wp_insert_post([
'post_title' => $title,
'post_name' => $slug,
'post_status' => 'publish',
'post_type' => 'page',
]);
if ($page_id && $template_name) {
update_post_meta(
$page_id, '_wp_page_template', $template_name
);
}
}
function bernad_create_service_pages() {
$services = [
'implantologia' => ['Implantología', 'page-implantologia.php'],
'endodoncia' => ['Endodoncia', 'page-endodoncia.php'],
'ortodoncia' => ['Ortodoncia', 'page-ortodoncia.php'],
// ... 9 more specialties
];
foreach ($services as $slug => $data) {
bernad_create_page_if_not_exists(
$slug, $data[0], $data[1]
);
}
}
add_action('after_setup_theme', 'bernad_create_service_pages'); 03
Templates.
16 dedicated pages
Especialidades clínicas
- Implantología
- Odontopediatría
- Endodoncia
- Prótesis
- Estética dental
- Cirugía oral
- Periodoncia
- Odontología restauradora
- Sedación
- Blanqueamiento dental
- Ortodoncia
Institucionales
- Instalaciones
- Tecnología
- Equipo
- Sobre nosotros
- Nuestra historia
- Servicios (hub)
Operacionales
- Financiación
- 404 personalizado
- Header / Footer compartidos
- Functions central
- JS + media propios
04
Stack.
Minimal · zero build complexity
Core
- WordPress
- PHP
- Tailwind CSS
- Custom theme
Templates
- 16 page templates
- Service-by-service
- Shared header/footer
- Auto-bootstrap
Conventions
- DRY helper functions
- Config-array driven
- after_setup_theme hooks
- Permalink flush automation