WP_Theme::get_template_directory_uri() WordPress Method

The WP_Theme::get_template_directory_uri() method is used to get the URL of the current theme's directory. This is useful for loading theme CSS and JavaScript files.

WP_Theme::get_template_directory_uri() #

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


Description

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


Top ↑

Return

(string) URL to the template directory.


Top ↑

Source

File: wp-includes/class-wp-theme.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 ) );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.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.