Ollie Theme Academy

Creating Template Parts

Template parts in classic themes

Classic themes use template parts for code reuse and consistency across multiple templates. The most common examples are header.php and footer.php, which appear on every page and follow WordPress conventions.

Template parts in classic themes also solve duplication problems when the same display code appears in multiple templates. Instead of copying code between index.php and archive.php, you create a shared template part that both can include.

The classic approach relies on functions like get_header() and get_footer() plus file naming conventions. These conventions are mandatory – without proper header.php and footer.php files, WordPress loads compatibility patches.

While functional, this system requires developers to understand numerous WordPress conventions and hook placements, adding complexity beyond the actual design and functionality work.

Back to: Ollie Theme Academy > Creating Template Parts