WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a theme index.php and it seems that when I use the "template_directory" it is not actually pulling the url path of the file, but instead is just pulling the main domain name. So instead of


its pulling the domain url and showing this


I don't understand why it's doing this, since the index.php file is actually in the right directory. (which is inside the theme folder). There is the index.php file that is in the wordpress directory... but I don't understand why it would conflict with the themes index.php file.

share|improve this question
Can you post the actual code you're using? Otherwise, it will be nearly impossible to help you. – Chip Bennett Sep 30 '11 at 20:51
up vote 2 down vote accepted

To get the exact path of image which is placed in http://example.com/wp-content/themes/theme_name/images/pic.jpg in your theme.

All you have to use below code:

  1. To show image
<img src="<?php bloginfo('template_url'); ?>/images/pic.jpg" />
share|improve this answer
The bloginfo() template tag already echoes its result; you don't need to echo it explicitly. bloginfo() echoes its result, while get_bloginfo() returns its result. Also, I strongly recommend using get_template_directory_uri() in place of get_bloginfo( 'template_url' ). – Chip Bennett Oct 3 '11 at 12:58
thanks, this worked. – Joshua Howell Oct 13 '11 at 16:39

I suspect one of two things:

  1. You're not using the correct template tag.

    Are you using get_template_directory_uri() or something else?

  2. You're not echoing the result

    If you're using get_template_directory_uri(), you have to echo it; e.g. this:


Will result in:

<a href="/images/pic.jpg">Link</a>

So, you need to do this:

<a href="<?php echo get_template_directory_uri(); ?>/images/pic.jpg">Link</a>

Which will result in:

<a href="http://www.example.com/wp-content/themes/theme-name/images/pic.jpg">Link</a>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.