I was reading this article: Common WordPress Development Mistakes and How to Fix Them, and in it, they author says:
Getting the theme location: If you are using TEMPLATEPATH or bloginfo(
‘template_directory’). Stop! You should be using the very useful
get_template_directory() as seen in my examples above.
But he doesn’t elaborate. What’s so bad about bloginfo()
?
To make a long story short:
get_bloginfo( 'template_directory' )
andget_bloginfo( 'template_url' )
simply returnget_template_directory_uri()
.So, you can shortcut that second call simply by referring directly to the latter template tag.
Refer to source for
get_bloginfo()
.A few others:
'url'
=>home_url()
'wpurl'
=>site_url()
'stylesheet_url'
=>get_stylesheet_uri()
'stylesheet_directory'
=>get_stylesheet_directory_uri()
'locale'
=>get_locale()
Edit
Note also:
TEMPLATEPATH
andSTYLESHEETPATH
are slated for deprecation, so you are better off simply replacing them now, withget_template_directory()
andget_stylesheet_directory()
, respectively.Edit 2
Re: this comment
Refer back to source 🙂
Re: this comment:
True, but that’s always been the case.
get_bloginfo()
doesn’t return anything related toget_stylesheet_directory()
. It only returnsget_stylesheet_uri()
andget_stylesheet_directory_uri()
.