Automatically Apply Custom Page Templates

A lot of WordPress themes include custom page templates. These can be used to create a different layout than the standard page.php file. Originally this was used (and is still a valid use-case) to provide just a marginally different layout such as removing the page’s sidebar.

As the WordPress ecosystem grew so did the use cases for custom page layouts. Separately styled pages for eCommerce cart & checkout pages, account pages, contact pages, and more became very common. The developer documentation for page templates suggests that these one-time use templates should not be given the traditional PHP comment header to avoid having them appear in the “Page Attributes” meta box.

(more…)

Better View Handling in WordPress Themes

WordPress theme structure has largely stayed the same for the last 15 years. There are many great thing about the build in templating system in WordPress, such as the extensive and flexible hierarchy loading system, helpful conditional tags, and more.

However as themes become more complex the forced expectations of where template files are located can become frustrating. Looking at a theme’s root directory and finding a mix of stylesheets, template files, configuration files, project documentation, shell scripts, and more can be overwhelming.

(more…)