get_template_directory_uri() WordPress Function

The get_template_directory_uri() function is a WordPress function that returns the URL of the current theme's directory.

get_template_directory_uri() #

Retrieves template directory URI for the active theme.


Return

(string) URI to active theme's template directory.


Top ↑

More Information

Top ↑

Notes

  • Checks for SSL
  • Does not return a trailing slash following the directory address

Top ↑

Source

File: wp-includes/theme.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More