WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was using the entire template in the plugin, but I would like to use get template part, so that I can reuse the header and footer in the original template. The code is like this:

add_filter( 'page_template', 'template_reg' );
function template_reg()
  if ( is_page( ourdoctors_single_pg() ) ) {       
  $page_template = dirname( __FILE__ ).'/templates/OurDoctors.php';
  return $page_template;       

Is there any way that I can use partial template instead of entire template? I tried to use get_template_part, but it seems like I have to put template in the theme. But how to put the template in the plugin?

share|improve this question
up vote 4 down vote accepted

Yes, get_template_part will always look in the theme. It uses locate_template which is hard-coded to use STYLESHEETPATH and TEMPLATETPATH

I don't know exactly what you mean about using a "partial template", but if you mean "can I include part of a PHP file?" then no. It is all or nothing. You need to break your file into multiple files or break the file's contents into granular functions that you can call as needed.

share|improve this answer
Thank you. I am going to write a child template. – Pluto Apr 8 '13 at 17:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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