Title: Internalize Plugin Template
Last modified: August 20, 2016

---

# Internalize Plugin Template

 *  [abowmedia](https://wordpress.org/support/users/abowmedia/)
 * (@abowmedia)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/internalize-plugin-template/)
 * Hello,
 * I dived into Custom Post types this week and made myself a nice neighborhood 
   listing module. My functions.php file is getting a little lengthy, and I plan
   to port this code into other sites I create, so I decided to make it into a plugin.
   I created a hierarchical custom post type, and turned “has_archive” on. Everythings
   working great, and I have 2 templates that control the archive page, and one 
   for the single page (archive-neighborhoods.php and single-neighborhoods.php).
   These templates work just fine from the theme’s folder.
 * My question is, if I wanted to move these 2 template files out of my theme folder,
   and into the plugin folder, so that I can just install the plugin into other 
   sites without having to move the template files into the folder, how would I 
   go about this?
 * This is the code I tried to use to pull in the single page template, but unfortunately
   it did not work, and i’ve been scouring Google for days and just can’t seem to
   find an answer:
 *     ```
       add_filter('single_template', 'my_custom_template');
   
       function my_custom_template($single) {
           global $wp_query, $post;
   
       if ($post->post_type == "neighborhoods"){
           if(file_exists(PLUGIN_PATH. '/single-neighborhoods.php'))
               return PLUGIN_PATH . '/single-neighborhoods.php';
       }
           return $single;
       }
       ```
   
 * I need help figuring out that as well as the archive page. Any ideas or direction
   with this would be most definitely appreciated..

The topic ‘Internalize Plugin Template’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * 0 replies
 * 1 participant
 * Last reply from: [abowmedia](https://wordpress.org/support/users/abowmedia/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/internalize-plugin-template/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
