Get_template_directory vs Get_template_directory_uri – Explained

In this short article, I am going to talk about the difference between get_template_directory vs get_template_directory_uri. If you are a beginner WordPress Theme Developer, it may create confusion. Let’s know in details what should we use while creating a WordPress theme.

Get template directory vs Get template directory uri


Get Template Directory is a function which returns the absolute template path directory of the theme. It generates the hosting directory of the template. Please check the example below.


Example Uses:

include (get_template_directory().'/includes/myfile.php');

It is the result which this function returns. You can use this function to include the template directory in your WordPress theme. Please note that this function should be used inside the include function.


It is almost the same, but it retrieves the full URI of the template directory. You can use it to print the URL of the template directory. It retrieves the full URI including the http://. You can use it outside of the Include function. Generally, we use get_template_directory_uri() function to print the style.css or javascript source. You can also use it to print for any other reasons. Get_template_directory_uri() prints like that.


Please check the picture below for better understanding.


Example Uses:

 <link rel="stylesheet" type="text/css" href="<?php echo esc_url(get_template_directory_uri()); ?>/style.css"/>

Both are important for developing a professional WordPress theme. But their uses are a little bit different. It is just using them inside the include function or outside the include function. That’s it.

Get Template directory URI ImageHope you got the point. It is effortless to understand. I would like to inform you more about our website. You will get a lot of valuable information and code snippets on our site.

If you would like to install a plugin in WordPress, please read our article about installing a plugin. How to install a plugin in WordPress.

If you are a beginner and if you would like to create¬†a website from scratch, you don’t have to pay $1500+ to the developers. You can do it yourself by following our article. Please read how to create a website using WordPress from the beginning. It is entirely free for you. We sell services, but we try to give our readers the best article.

Get_template_directory vs Get_template_directory_uri – Explained
Rate this post
LLN Team

About The Author : LLN Team

We are LLN Team promise you to provide you useful information about website and blog creation. We will focus on WordPress and other essential needs. Keep browsing Lets Learn Now. Cheers

Leave a Reply

Your email address will not be published.

Please post a relevant comment and make the conversion informative.