get_template_directory_uri()WP 1.5.0

Retrieve current theme directory URI. Returns the URL to the root theme, not a child one. Doesn't contain a closing slash at the end.

You can also use get_bloginfo('template_url'); instead of this function.

If a child theme is used and you want to get its URL, use get_stylesheet_directory_uri().

If you want to get the path to the theme directory (folder), use get_template_directory().

If you want to get URL to the plugin, use plugin_dir_url().

1 time — 0.002132 sec (very slow) | 50000 times — 3.37 sec (fast) | PHP 7.1.2, WP 4.7.3
Hooks from the function


String. URI to active theme's template directory.





#1 Get the URL to the theme

echo get_template_directory_uri();

// output:

#2 Including a script

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
function my_scripts_method() {
		get_template_directory_uri() . '/js/custom_script.js',


Since 1.5.0 Introduced.

Code of get_template_directory_uri() WP 6.0

function get_template_directory_uri() {
	$template         = str_replace( '%2F', '/', rawurlencode( get_template() ) );
	$theme_root_uri   = get_theme_root_uri( $template );
	$template_dir_uri = "$theme_root_uri/$template";

	 * Filters the active theme directory URI.
	 * @since 1.5.0
	 * @param string $template_dir_uri The URI of the active theme directory.
	 * @param string $template         Directory name of the active theme.
	 * @param string $theme_root_uri   The themes root URI.
	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );