Title: Plugin template path.
Last modified: August 22, 2016

---

# Plugin template path.

 *  Resolved [jannnik](https://wordpress.org/support/users/jannnik/)
 * (@jannnik)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-template-path/)
 * Hi,
 * I wrote a plugin which extends the functionality of Job Manager and made some
   custom templates, which are actually in my theme folder to override the original
   templates.
    Now, I would like to add the templates to the plugin folder to make
   my plugin undependent to the theme. I read the section in your wiki how to add
   a filter for the template location, but I didn’t managed it to use a custom template
   location in the plugins folder.
 * Could you provide an example how to add a filter to use the plugin folder instead
   of the theme folder for template overrides?
 * [https://wordpress.org/plugins/wp-job-manager/](https://wordpress.org/plugins/wp-job-manager/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5547915)
 * If you’re hoping to override CORE template files via your plugin, the plugin 
   uses a filter which gives you that opportunity.
 * `return apply_filters( 'job_manager_locate_template', $template, $template_name,
   $template_path );`
 * Filter job_manager_locate_template, check what $template_name is being filtered
   and return the updated path.
 *  Thread Starter [jannnik](https://wordpress.org/support/users/jannnik/)
 * (@jannnik)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548062)
 * Yes, I want to override core template files from wp job manager. I read this 
   post: [https://wordpress.org/support/topic/template-overrides-via-plugin](https://wordpress.org/support/topic/template-overrides-via-plugin)
   ,
   but I really need an example how to write the filter. The only thing I need is
   to have a template folder in my plugin directory which works like the folder 
   in the theme directory.
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548063)
 * The filter I posted is what you need. If you’ve written a plugin, surely you’re
   familiar with filter syntax? Basic example:
 *     ```
       add_filter( 'job_manager_locate_template', 'custom_job_manager_locate_template', 10, 3 );
   
       function custom_job_manager_locate_template( $template, $template_name, $template_path ) {
          return 'somenewtemplatepath';
       }
       ```
   
 *  Thread Starter [jannnik](https://wordpress.org/support/users/jannnik/)
 * (@jannnik)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548148)
 * Finally, I got it to work with this filter (it tries to load each template from
   my plugin’s folder, but if there is no custom template, it will use the original
   one.)
 *     ```
       add_filter( 'job_manager_locate_template', 'custom_job_manager_locate_template', 10, 3 );
       function custom_job_manager_locate_template( $template, $template_name, $template_path ) {
       	$plugin_path = dirname(__FILE__) . '/templates/' . $template_name;
       	if (file_exists($plugin_path))
       		return $plugin_path;
       	else
       		return $template;
       }
       ```
   
 *  Thread Starter [jannnik](https://wordpress.org/support/users/jannnik/)
 * (@jannnik)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548151)
 * But there is a problem again. It seems like this filter only filters the “job-
   filters”-templates, but not the “content”-templates. (I use the [jobs] shortcode).
   Could you test my filter and find the reason why it does not work as expected?
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548152)
 * Those ones are not filtered. Log an issue on github.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Plugin template path.’ is closed to new replies.

 * ![](https://ps.w.org/wp-job-manager/assets/icon-256x256.gif?rev=2975257)
 * [WP Job Manager](https://wordpress.org/plugins/wp-job-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-job-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-job-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-job-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-job-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-job-manager/reviews/)

## Tags

 * [addon](https://wordpress.org/support/topic-tag/addon/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 6 replies
 * 2 participants
 * Last reply from: [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/plugin-template-path/#post-5548152)
 * Status: resolved