Blog PHP Function to Grab WordPress Theme Location
June 25, 2013 Development, HTML, PHP, WordPress Social Share
<img src="/wp-content/themes/my-theme/images/my-image.jpg" alt="My Image" />
There are a couple reasons to not static code the theme location:
The correct way to add this link to your theme is the bloginfo() function. You can see below that it replaces the “/wp-content/themes/my-theme” portion of the image URL.
<img src="<?php bloginfo('template_directory'); ?>/images/my-image.jpg" alt="My Image" />
Now your theme can be installed in any directory or with any name and still work just fine.