Wordpress Web Application Development(Third Edition)
上QQ阅读APP看书,第一时间看更新

Creating custom templates

Themes provide a default set of templates to cater to the existing behavior of WordPress. Here, we are trying to implement a custom template system to suit web applications. So, our first option is to include the template files directly inside the theme. Personally, I don't like this option due to two possible reasons:

  • Whenever we switch the theme, we have to move the custom template files to a new theme. So, our templates become theme-dependent.
  • In general, all existing templates are related to CMS functionality. Mixing custom templates with the existing ones becomes hard to manage.

As a solution to these concerns, we will implement the custom templates inside the plugin. First, create a folder inside the current plugin folder and name it templates to get things started.