Skip to content
ookhrimenko edited this page Jan 17, 2018 · 11 revisions

Theme Boilerplate with a modern code structure

Theme Boilerplate is a WordPress starter theme, which can be used to start the development of custom themes quickly. It's useful for big projects with several unique templates, long-scroll landing pages, custom post types, and custom queries.

This theme requires a WordPress Theme Framework plugin. Theme Framework consists of a base code, which can be used to create your very own theme.

Better file structure

The organization of the theme is very similar to modern PHP Frameworks. We separated registration of hooks and components, query logic and the templates.

File structure

Object-oriented. Code autoload

The main code is written with classes, using best practices of inheritance and incapsulation. Autoload technique helps to load only classes we need for a particular page (faster loading).

Folder structure helps to quickly find small pieces of code you need to write or update.

Improved Templates Structure

All templates are now grouped by post type (like page or post) or by section (like search, widgets). When you develop a big site with a lot of custom templates, it's handy to find the correct template.

Furthermore, folder grouping does not break standard WordPress Template Hierarchy. You can use the same template names as you usually do. Just place them in a post-type-related folder!

Template Inheritance

We added a modern template inheritance system based on layouts (very similar to Laravel and Yii frameworks). Some WordPress developers call it a "Theme Wrapper". Markup is handled by one layout file (or more if needed) instead of being scattered across all template files as in typical themes. Stay DRY!

Security and optimizations

Theme files are nice and clean, but Theme Framework has a lot of hooks to make your WordPress more secure, clean up and optimize the final generated HTML.

Boilerplate-based theme generator

We have completed our WordPress Starter with custom composer commands, which generate a theme with a custom name, namespace, and text domain.


Next: Installation