0

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?

4

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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