Alex Mansfield

Building Extensible Themes With Hooks And Filters

There are two common methods of building WordPress themes. First, popular themes like _s and the default themes are primarily HTML combined with some template tags. This method is easy to understand and is great for beginners and projects that don’t need to be extensible. Second, there are powerful theme frameworks that recreate the entire theming system. These are great for extensibility, but come with a steep learning curve. In this talk, I would like to explore a third option that uses the WordPress hook and filter system to find a comfortable middle ground. Using this method, the index.php file is used as starting point, with all of its output added via hooks and filters. Additional page templates simply add or remove actions from these hooks and filters. This methodology allows new templates to be created quickly and easily. Existing templates can also be modified on a per-use basis. To get the most out of this session, familiarity with WordPress Theme development and PHP are recommended. Knowledge of the WordPress hook/filter system will be helpful, but not required.