Support » Plugins » Hacks » How to use 'Template Name:' in plugins?

  • I’m using the Template Name: comment tag in a file located in my plugins root directory, see code below. But WordPress refuses to recognize this page template. Do I have to include the file somehow inside my plugin? I do not want the user to manually create files in the theme directory to get things running, it should work ‘out of the box’. There must be an easier way, right?

    Template Name: MyPageTemplate
    // more code...
Viewing 1 replies (of 1 total)
  • Not that I’m aware of. There are good reasons why plugins and themes (+templates) are separate entities.

    Though there is a black hat way to achieve this. And I mean “black hat” because no one likes it if someone else messes with your product/theme/code. All kinds of things could happen!

    If you still insist, get the current theme’s directory and if your page template file does not exists there, copy it from your plugin directory to that destination.

    But again, this could go ugly and backfire on you in so many ways I would not recommend doing it

Viewing 1 replies (of 1 total)
  • The topic ‘How to use 'Template Name:' in plugins?’ is closed to new replies.