This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_template_directory_uri/
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 that 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
.
Theme paths: get_template(), get_template_directory(), get_template_directory_uri(), get_theme_roots(), get_theme_root(), get_theme_root_uri(), get_stylesheet(), get_stylesheet_uri(), get_stylesheet_directory(), get_stylesheet_directory_uri(), get_bloginfo(), get_theme_file_uri(), get_theme_file_path()