Title: WP_Theme::get_template_directory_uri
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Theme::get_template_directory_uri(): string

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#wp--skip-link--target)

Returns the URL to the directory of a theme’s “template” files.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#description)󠁿

In the case of a child theme, this is the URL to the directory of the parent theme’s
files.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#return)󠁿

 string URL to the template directory.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#source)󠁿

    ```php
    public function get_template_directory_uri() {
    	if ( $this->parent() ) {
    		$theme_root_uri = $this->parent()->get_theme_root_uri();
    	} else {
    		$theme_root_uri = $this->get_theme_root_uri();
    	}

    	return $theme_root_uri . '/' . str_replace( '%2F', '/', rawurlencode( $this->template ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-theme.php#L1216)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-theme.php#L1216-L1224)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Theme::get_theme_root_uri()](https://developer.wordpress.org/reference/classes/wp_theme/get_theme_root_uri/)`wp-includes/class-wp-theme.php` |

Returns the URL to the directory of the theme root.

  | 
| [WP_Theme::parent()](https://developer.wordpress.org/reference/classes/wp_theme/parent/)`wp-includes/class-wp-theme.php` |

Returns reference to the parent theme.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.4.0](https://developer.wordpress.org/reference/since/3.4.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/?output_format=md#comment-content-2590)
 2.   [jakeparis](https://profiles.wordpress.org/jakeparis/)  [  9 years ago  ](https://developer.wordpress.org/reference/classes/wp_theme/get_template_directory_uri/#comment-2590)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme%2Fget_template_directory_uri%2F%23comment-2590)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme%2Fget_template_directory_uri%2F%23comment-2590)
 4. This does _not_ return a trailing slash.
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme%2Fget_template_directory_uri%2F%3Freplytocom%3D2590%23feedback-editor-2590)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme%2Fget_template_directory_uri%2F)
before being able to contribute a note or feedback.