How to Provide Page Templates in Plugins

Paulund has a nice little tutorial about something I’ve done once or twice, but haven’t managed to ever write down or remember well: how you can provide page templates in a plugin.

Page templates, if you remember, are the drop-down on the right of Page post types in WordPress. By default, they’re only looked for and provided by a theme. But sometimes you can and will want one supplied by a plugin. Unfortunately, that’s not super easy or elegant in WordPress. But it is possible, and this little tutorial shows you how. Definitely worth a glance, even if you don’t intend to do it soon.

The core filters: theme_page_templates and template_include.


Add a Comment

Your email address will not be published. Required fields are marked *