Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.