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.
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.
Please check the picture below for better understanding.
<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.
Hope 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.