Creating Custom Templates in a Plugin Instead of Your Theme

Let me start this with a disclaimer: custom templates go in your theme. That’s what themes are for: giving you interesting ways to display your WordPress site’s data.

But once in a blue moon, you may need to write new custom templates into a plugin. Why? Well, I’m currently working for a client on a site I didn’t build, and the project isn’t using a child theme. To move it onto a child theme would be nice, but that would risk losing whatever theme options are set on the parent theme, which might be extensive. It just doesn’t feel worth it to risk the steps backward, just to get one new page template (which is what the client needs) happening.

The linked tutorial from WPExplorer is very good and works out of the box; you just need to write the file names and display names of your new templates into the array in the middle part of the code.

Add a Comment

Your email address will not be published.