Take the 2-minute tour ×

Basically I've used bloginfo(template_url) in a WordPress theme, but when I run theme-checker, it recommends to replace bloginfo(template_url) with get_template_directory_uri(), however when I use get_template_directory_uri() it doesn't work. It works fine if I use it to replace get_bloginfo(template_url) but that's not what I want now. Is bloginfo(template_url) being deprecated? If it is, what is it's replacement?


share|improve this question

5 Answers 5

up vote 5 down vote accepted

bloginfo($option) echos out a value whereas get_template_directory_uri() returns a string - did you maybe forget to echo get_template_directory_uri()? Also are you passing a string with quotes i.e. bloginfo(template_url) vs bloginfo('template_url')?

Both bloginfo('template_url') and get_template_directory_uri() should work, they aren't deprecated.

share|improve this answer
Firstly I do need a value rather than a string, so I'm using bloginfo($option). Also, everything is working fine in my theme while using bloginfo($option). The problem I have is when I use theme-checker it recommends that I should use get_template_directory_uri() instead, but when I did, it didn't work. Should I just ignore theme-checker's recommendation? –  WagnerMatosUK Jul 12 '12 at 7:43
I would ignore it. I personally use get_bloginfo() over get_template_directory_uri() and don't see any reason why it's better to use one function over the other –  Rezen Jul 12 '12 at 16:07
Good to know! Just odd that theme-checker suggest a change that doesn't seem to be necessary... Anyway, thanks for the help. –  WagnerMatosUK Jul 13 '12 at 8:13

This is the right way -

<?php echo get_template_directory_uri(); ?>
share|improve this answer

bloginfo is a wrapper for get_bloginfo, which just calls those functions directly:

    case 'stylesheet_directory':
        $output = get_stylesheet_directory_uri();
    case 'template_directory':
    case 'template_url':
        $output = get_template_directory_uri();

so it's ultimately exactly the same output.

share|improve this answer

You Can use both

<?php echo get_template_directory_uri(); ?>
share|improve this answer
The echo in front of bloginfo() is not needed. –  Geert Jul 12 '12 at 5:46
yeah..thats not needed.sorry about that.its should be get_bloginfo –  Monirul Islam Jul 12 '12 at 6:02
The code I'm using is: <img class="big_divider" src="<?php bloginfo('template_url'); ?>/images/dividers/big_divider.png" alt="content divider" /> and is working perfectly how I wanted. The thing is that theme-checker recommends that I use get_template_directory_uri() instead which doesn't work when I did use it, so it made me wonder whether bloginfo($option) is being deprecated. If not, why is theme-checker suggesting to replace it? –  WagnerMatosUK Jul 12 '12 at 7:49

The correct way should be (imho)

<?php get_bloginfo('template_url'); ?>

Rationale: The function get_template_directory_uri(), besides being long, also has a slightly misleading name. It doesn't not return a directory and not a uri either (the identifier would be the theme name not it's location)

So, for typing reasons as well as self-documenting reason the get_bloginfo is better.

Replacing is not needed.

share|improve this answer
If you prefer to do it with get_bloginfo( $option ) that is okay, but your statement above does not do anything, as it just returns a value. Either echo it or use bloginfo();. –  fischi Mar 18 '13 at 15:38
No. This is wrong. Use get_template_directory_uri(). And it's more efficient, too: get_bloginfo( 'template_url' ) merely calls get_template_directory_uri() anyway. –  Chip Bennett Mar 18 '13 at 15:49

Your Answer


