Created
June 11, 2014 19:01
-
-
Save drwpow/fce83a7e6a822379aca3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----- functions.php -----// | |
$site_url = get_bloginfo('url'); | |
$template_url = get_bloginfo('template_directory'); | |
//----- index.php (or wherever) -----// | |
<?php | |
global $site_url; | |
global $template_url; | |
?> | |
<img src="<?= $template_url ?>/img/myimage.jpg"> |
You could just run get_bloginfo('template_directory')
whenever you wanted to grab the template path, but your DB queries will skyrocket if you do that several times on the page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to declare
global $template_url;
in a PHP block near the top in whatever template you want to use this variable.