After spending several years in the WordPress space, Metodiev collected some of our code snippets and best practices, as well as challenging moments while working with 3rd party theme authors or migrating customers with poorly written themes.
Stanko described some of the major issues with using off-the-shelf themes. The larger theme marketplaces focus on themes that bundle everything with them – sliders, portfolio items, products and what not, which is against the idea of themes in the first place – being used for presentation only.
He explained the best way of bundling scripts and reusing the ones being a part of the WordPress core. Additionally, post type and custom taxonomy functionality can be built into plugins, which are then added with the TGM Plugin Activator. Ignoring that simple rule could lead to heavy consequences, especially when major plugins are embedded in a theme and a serious vulnerability is found.
The talk included the proper way to use WordPress Queries and why we shouldn’t use query_posts, why are the Coding Standards essential for backwards compatibility, performance and security, and how we can use the Theme Unit Test data to validate the right behavior of a custom theme.
Stanko presented a few ways to enqueue scripts and styles with WordPress and extend the behavior of a theme with additional classes for the HTML body and post containers. He reviewed the default home.php and front-page.php templates from the WordPress Theme Hierarchy, when to use them and how to create custom page templates, too. Handy snippets and functions such as get_template_part() were also demonstrated, setting up a theme the right way, functions for data sanitization and various core features and popular free plugins that could be embedded in a theme in an elegant way.
As a final statement, Metodiev explained that we should be responsible when building custom themes. Appreciating cultural differences and people around the world, we must keep in mind internationalization, accessibility and other aspects such as RTL support.