Title: Using get_template_part inside folder
Last modified: August 20, 2016

---

# Using get_template_part inside folder

 *  Resolved [nelsonpatojimenez](https://wordpress.org/support/users/nelsonpatojimenez/)
 * (@nelsonpatojimenez)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/)
 * I’m using the function get_template_part inside folder but this fails.
 * For example:
 * -MainDirectory
    -DirectoryOne -FileOne.php -DirectoryTwo -FileTwo.php
 *  I’m trying to call from FileOne.php to FileTwo.php as follows:
 * <?php
    get_template_part(‘DirectoryTwo/FileTwo’); ?>
 * <?php
    get_template_part(‘../DirectoryTwo/FileTwo’); ?>
 * but don’t work. Any help ?.

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

 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612685)
 * I think you have to use the file names of the templates you want to get the part
   from, as well as specify the part.
 * should look something like
 *     ```
       <?php get_template_part( 'directory-two' ); (file-two.php) ?>
       ```
   
 * but of course “Directory2” has to exist as a template part in FileTwo.php. And
   of course, should use lowercase and dashes for the part and template name.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612692)
 * get_template_part accepts 2 parameters – the general template name, and the specific
   template name.
    [http://codex.wordpress.org/Function_Reference/get_template_part](http://codex.wordpress.org/Function_Reference/get_template_part)
 * That I know of, you can’t specify a directory
 * get_template_part( ‘this’, ‘that’ );
 * would look for a file named this-that.php first, and then this.php second
 * I am not certain if the get_template_part function looks into different directories
   for the requested file…
 * so for your usage, get_template_part( ‘FileTwo’ ); would call the file, but you’d
   have to test if it automatically looks into directories. You may need to use 
   an include here
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612711)
 * ah, thanks. I was confused about that directory title, assumed it was just a 
   name for a specific template part.
    Using get_template_part to get a different
   directory is something I’ve never coincided. I’ll yield to the experts on that
   one.
 *  Thread Starter [nelsonpatojimenez](https://wordpress.org/support/users/nelsonpatojimenez/)
 * (@nelsonpatojimenez)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612936)
 * thank’s for response!. When the file is out of a directory you can call to file
   inside of directory.
 * Example:
 * -RootDirectory(root of your template).
    FileOne.php
 * –SubDirectory
    FileTwo.php
 * Code of FileOne.php
 * <?php
    get_template_part(‘SubDirectory/FileTwo’); ?>
 * i used this code and it works.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612943)
 * cool, thanks for replying back with that info for others!
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612966)
 * appreciate it!

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

The topic ‘Using get_template_part inside folder’ is closed to new replies.

## Tags

 * [get_template_part](https://wordpress.org/support/topic-tag/get_template_part/)
 * [Themes](https://wordpress.org/support/topic-tag/themes/)
 * [using](https://wordpress.org/support/topic-tag/using/)
 * [worpdress](https://wordpress.org/support/topic-tag/worpdress/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/using-get_template_part-inside-folder/#post-2612966)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
