I’m using taxonomy_template filter in my plugin to load a template file for custom user taxonomies. This is the code I’m using

 add_filter( 'taxonomy_template', 'get_custom_taxonomy_template' );
 function get_custom_taxonomy_template($template) {

   $taxonomy = get_query_var('taxonomy');

   if (strpos($taxonomy,'rcm_user_') !== false) {
      $taxonomy_template = UT_TEMPLATES_URL ."user-taxonomy-template.php";
      $file_headers = @get_headers($taxonomy_template);
      if( $file_headers[0] != 'HTTP/1.0 404 Not Found'){
         return $taxonomy_template;
      }
   }
   return $template; 
}

It loads the file but I get fatal error for wordpress functions like

get_header(), _e()

I’ve tried using default theme, saving permalink structures.

2 Answers
2

Issue was with UT_TEMPLATES_URLused for including the template.

I was using file URL and not file PATH which was creating the issue.

Modifying the UT_TEMPLATES_URL, to FILE PATH fixes the issue.

Leave a Reply

Your email address will not be published. Required fields are marked *