WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/get template directory uri

Contents

Description

Retrieve template directory URI for the current theme. Checks for SSL.

Note: Does not return a trailing slash following the directory address.

In the event a child theme is being used, the parent theme directory URI will be returned, get_template_directory_uri() should be used for resources that are not intended to be included in/over-ridden by a child theme. Use get_stylesheet_directory_uri() to include resources that are intended to be included in/over-ridden by the Child Theme.

Usage

Use the URI <?php get_template_directory_uri(); ?>

Output the URI <?php echo get_template_directory_uri(); ?>

Parameters

None.

Return Values

uri (string) 
Template directory URI.

Examples

Using get_template_directory_uri() to enqueue a script with the correct path

<?php
function my_scripts_method() {
	wp_enqueue_script(
		'custom_script',
		get_template_directory_uri() . '/js/custom_script.js',
		array('jquery')
	);
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
?>

Notes

Change Log

Source File

get_template_directory_uri() is located in wp-includes/theme.php.

Related

See also index of Function Reference and index of Template Tags.