Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates The Header and Footer Templates

Jojo Ind
Jojo Ind
2,260 Points

What's the different between bloginfo template_directory and get_template_directory_uri ?

Hi, I'm confused, what's the different between these 2 function ?

They're both basically echoing the root folder of the wp, aren't they ?

So why the first one use "bloginfo" function and the second one use "get_template_directory_uri" function ?

bloginfo('template_directory');?>/images/favicon.ico

get_template_directory_uri() . '/css/bootstrap.min.css'

Thank you

1 Answer

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

from the Codex

[...]Within child themes, both get_bloginfo('template_url') and get_template() will return the parent theme directory. Consider echoing get_template_directory_uri() instead (for the parent template directory) or get_stylesheet_directory_uri() (for the child template directory).

Jojo Ind
Jojo Ind
2,260 Points

Thank you Roberto, for taking time to answer my question.