When I first started using WordPress, I found out about the bloginfo function, which gives you a lot of information about your blog. Normally I would use it to denote things like the site name (bloginfo(‘name’)), the blog description (bloginfo(‘description’)), and even to link to my scripts (bloginfo(‘template_directory’)).
I found out late about the functions get_template_directory_uri() and get_stylesheet_directory_uri(). What I couldn’t wrap my head around was which one was better to use. These new functions did the same as bloginfo(‘template_directory’) and bloginfo(‘stylesheet_directory’), so why should I use the other longer one? I decided that I didn’t want to use these new codes because the usage I had decided to go with was working.
However, the design industry only grows as new technology is adopted. So I decided I would try to figure out which of these is better. In my study, I’ve found that using get_template_directory_uri() and get_stylesheet_directory_uri() is better than using bloginfo for one good reason. bloginfo(‘template_directory’) will not check for SSL. So even if you are on a secure page (like a checkout page), bloginfo will return http:// version. This means that in some browsers, your stylesheets will not load, and you’ll have a broken site.
get_xxx_directory_uri() checks for SSL and will return the correct beginning to your URL (either http:// or https://). So now that we know which function set works better, how do we decide which one to use:
get_template_directory_uri() and get_stylesheet_directory_uri() will return the same thing if you are not using a child theme. If you are using a child theme, get_template_directory_uri() will return the page to the parent theme folder, while get_stylesheet_diretory_uri() will retun the child theme folder.