How to link to WordPress images folder in theme

The following line is the full URL to you images folder and how you would add it in the template. This sometimes is just to much to type or almost seems like there has to be a better solution.

<img src="yourblog/wp-contents/themes/yourtheme/images/yourimage.png" title="" alt="">

Well in this case there is. Just use the code below and it saves time, makes things easier and uses the WordPress codex.

<?php bloginfo('template_directory'); ?>/images/yourimage.png" title="" alt="" />

That will call to the images folder in your theme. Hope this helps

One Comment

Leave a Reply