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.
Use the URI
<?php get_template_directory_uri(); ?>
Output the URI
<?php echo get_template_directory_uri(); ?>
None.
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');
?>
get_template_directory_uri() is located in wp-includes/theme.php.