Support » Plugins » How to embed a template file in a plugin?

  • I am writing a plugin to add a custom post type. I would like to include a template file in the plugin file. The template file is currently located in /wp-content/themes/twentyeleven/single-$posttype.php. I’ve tried to search this site and looked through the Codex, but didn’t find what I’m looking for.

    Any help is appreciated,
    Ryan

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Ryan Marks

    (@rmarks)

    A little clarification… what I mean is to include a template file inside my plugin directory and have the custom post type use that file in lieu of single-$posttype.php within the theme folder. I have heard of plugin authors who create their own widgets. They include a template file for the widget, but allow it to be overridden when the theme has a template for that widget. I’m looking to do the same. Include a template file with the plugin so no one has to recreate a theme for this CPT.

    Thread Starter Ryan Marks

    (@rmarks)

    Okay, it took some trial and quite a bit of error, but I figured out some code that works. See it here: http://pastebin.com/7RhLLNS9

    Dharma

    (@dharmashanti)

    Thanks for sharing that! I was just wondering how to do that!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to embed a template file in a plugin?’ is closed to new replies.