Building a custom template comes down to three steps: a structured foundation made of semantic HTML elements, a presentation layer written in responsive CSS, and a connection between the static layout and a content management system. In WordPress, that third step now works differently than it did a few years ago. Block themes and the theme.json file have replaced a large part of the work that used to live in PHP templates. For the full decision between block, classic and hybrid themes, see how to develop a custom WordPress theme.
What a custom template is and when it earns its cost
A custom template is a structure built for one specific project rather than an adaptation of an existing theme. It gives you control over every aspect of presentation and behaviour.
The main advantage is freedom of decision. You are not working around another theme’s constraints or fitting your project into a structure designed for something else. On complex business applications and commerce platforms, that is usually a precondition rather than a preference.
The performance argument deserves precision, because it is often overstated. A theme built for one project does not load code handling dozens of scenarios you will never use, so it typically generates fewer queries and lighter assets. That is not a guarantee of better search rankings. Performance is one signal among many, not the sum of them.
A custom template earns its cost where a project is meant to run for years and be developed by a team. For a one-off site with a simple structure, an existing theme is usually enough.
How do you structure the basic HTML framework?
The foundation starts with a DOCTYPE declaration and a semantic document structure. That ensures consistent rendering across browsers and devices.
The document structure covers:
- a DOCTYPE declaration for HTML5
- an
htmltag with a language attribute - a
headsection with metadata, title, and resource references - a
bodysection with semantic containers
Your head should include a viewport meta tag, a character encoding declaration, and references to stylesheets and scripts. The viewport tag determines whether the template displays correctly on mobile devices. At the individual page level, there are five different ways to build a custom page in WordPress, from patterns to a full custom plugin.
Inside body, use semantic elements: header, nav, main, article, section, aside, footer. They give meaning to the content structure, which affects accessibility and how search engines interpret the site.
Semantics now carry a regulatory dimension as well. The European Accessibility Act has been enforceable since June 2025, and in Poland the compliance requirement extended to e-commerce among other sectors. A template built on div elements without a heading hierarchy, with no ARIA roles and no considered focus order, will not pass a WCAG 2.1 AA audit. Retrofitting a finished layout costs several times more than getting the structure right at the start.
What CSS techniques are essential for responsive template design?
Mobile-first design is the starting point. You design for the smallest screens first, then extend the layout upwards with media queries.
Flexbox and CSS Grid provide the tools for layouts that adapt to screen size. Flexbox handles one-dimensional layouts such as navigation bars and card sets. CSS Grid handles two-dimensional layouts with full control over rows and columns.
| Technique | Best use case | Key benefit |
|---|---|---|
| Flexbox | navigation, card layouts | flexible content alignment |
| CSS Grid | complex page layouts | two-dimensional control |
| Media queries | responsive breakpoints | device-dependent styling |
| Container queries | reusable components | styling driven by the container, not the viewport |
| Relative units | scalable typography | proportional sizing |
Set breakpoints where the layout stops working, not from a list of popular device widths. Values around 768px and 1024px are a starting point, not a rule.
Container queries (@container) now have support across all major browsers and work better than media queries for component libraries. A component then responds to the width of its container rather than the whole window, which matters for blocks placed in different layout columns.
Use relative units: rem, em, and percentages instead of fixed pixels. The template then scales correctly against user settings, which is also an accessibility requirement.
How do you connect the template to WordPress: block themes and classic themes
This is where the most important change of recent years sits. WordPress now supports two theme models, and choosing between them is an architectural decision rather than a matter of taste.
Block themes (Full Site Editing)
In a block theme, templates are .html files in the templates/ directory containing block markup rather than PHP. Reusable fragments such as the header and footer go into parts/.
The core of such a theme is theme.json. It defines the colour palette, the typographic scale, the spacing grid, and settings for individual blocks. In practice it is a design system expressed as configuration. Changing a value in one place propagates across the whole site, with no hunt for overrides in stylesheets.
On top of that sit block patterns, ready-made section layouts that a marketing team assembles in the editor without help. That is the strongest business argument for this model: editorial staff build new pages and landing pages without a developer in the loop for every change.
Classic themes
The model based on PHP templates, functions such as wp_head(), wp_footer(), and the_content(), and the WordPress loop still works and still has its uses. You choose it when a project needs complex database queries, non-standard rendering logic, or when you are taking over an existing site where migrating to the block model would be a project in its own right.
Hybrid arrangements are common in practice: a classic theme with a custom block library for the editorial team. On mature sites being taken over, that is often the most sensible compromise.
The data layer
Custom fields and Advanced Custom Fields extend the data model beyond standard WordPress capabilities. They support the structures needed for more demanding applications, from property catalogues to training platforms.
Extension points, meaning actions and filters, let you add functionality without modifying theme files. Changes then survive updates and stay maintainable.
What to watch for when building a custom template
Success depends on planning and testing at every stage. The work starts with wireframes and designs, not with code.
Validate HTML and CSS regularly using validators and browser developer tools. Test the template across devices and browsers before it reaches production.
Keep the code readable, commented, and consistent with established conventions. Meaningful class names and consistent formatting determine what it costs for the next person to take the project over.
Common mistakes include skipping responsiveness, over-complicated CSS selectors, and unoptimised assets. There is one more that only surfaces months later: the absence of a design system. A template with no shared variables for colour, typography, and spacing starts drifting by the third or fourth page added by a different person.
Version control in Git is a standard, not an option. On team work and larger template changes it is the only way to reconstruct what changed and when.
Maintenance is the final piece. Web standards move and functions get deprecated. A periodic template review, updates to deprecated code, and performance verification all belong on a schedule.ence.



