I am currently starting a plugin development project and ideally I'd like the plugin to run using its own custom theme as if it was it's own separate thing.

Is it possible to include a theme within the plugin that has its own custom page layout etc and would only use that template when the related pages are accessed?

The idea is to have the ability for users to log-in to a members only area using wordpress' log-in.

Is this possible or something I need to rethink?


1 Answer 1


I don't quite know what you mean by "include a theme" and you are talking about a potentially large and complicated project but I think you should be able to control the display of your plugin content with the template_redirect hook.

function template_redir_wpse_99209($content) {
  // code or file include, for example
  // exit;

You can echo your page content and then exit, or include a file from anywhere, including your plugin. You don't have to redirect to a theme template.

It is a bit of a hack but I don't know of another way to "inject" a page. This is "theme" territory. The theme usually controls content display.

There is also the template_include hook but you'd be looking at the same kind of exit hack.

I don't know how friendly this will be, since you are completely hijacking what is usually theme territory. I'd at least consider allowing the theme to override your defaults.

  • This seems like it does what i want it to do. Thanks! The only problem i see is the fact it looks like it needs to have another template installed to redirect to. Is there anyway to install a theme automatically with the plugin as well as make sure the user cant activate it accidentally?
    – MobliMic
    May 12, 2013 at 19:28
  • @Mobli, it surely needs a template to redirect. Ain't you talking about "embedding" a theme inside your plugin? Check how WPTouch handles it.
    – brasofilo
    May 12, 2013 at 19:38
  • @Mobli : See the edit.
    – s_ha_dum
    May 12, 2013 at 19:43
  • @brasofilo Thanks that seems like the way i need to go :D
    – MobliMic
    May 12, 2013 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.