get_template_directory_uri() function returns the URL to the root theme, It means when you will add a custom css, image or js files in theme template files, then you will require to give a full path to load new file and this function will help you to provide theme root path.
get_template_directory_uri() >> http://yourdomain.com/wp-content/theme/your-theme
Example:
I want to add a new js file i.e abc.js in header of the theme. I have uploaded abc.js file under js folder of theme.
Now I have call this js file in header.php with a normal path js/abc.js and check it in front-end, File will return 404 not found error because by default new js file will take website home root path url and that's why it always not load in front-end and return 404 error.
Now question is that How I can define full path theme to load this new js file, then I will say that you should use get_template_directory_uri() function.
Now this will work very well and this time your new js file will load into header .
Error :
<script src="js/abc.js">
Success:
<script src="<?php get_template_directory_uri()?>/js/abc.js">
Note:
If a child theme is used and you want to return the URL to the current child theme, use get_stylesheet_directory_uri() instead.