2011-12-02 74 views
0

我怎样才能使这个工作?提前致谢!!!我认为首先应该回声工作,但它不...它打印出的URL文本,而不是显示图像...WordPress模板目录

<?php 
     if (is_tree(18)) { 
     echo '<img src="' . bloginfo('template_directory') . '/img/icon-trans.png" />'; 
     } else if (is_tree(20)) { 
      echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconIndustrial-trans.png' />"; 
     } else if (is_tree(22)) { 
      echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconInstitutional-trans.png' />"; 
     } else if (is_tree(24)) { 
      echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconComm-trans.png' />"; 
     } else if (is_tree(27)) { 
      echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconService-trans.png' />"; 
     } else if (is_tree(39)) { 
      echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconTraffic-trans.png' />"; 
     } else { 
     echo ""; 
     } 
     ?> 
+0

您是否已经在一个PHP代码块,或不??? –

+0

是的,我。谢谢阅读! –

回答

1

而不是使用代码bloginfo( 'template_directory')使用get_bloginfo( 'template_directory')

+0

完美的作品!谢谢你们俩!!! –

0

你不应该打开另一个PHP模块,因为这将打破你的代码。

使用连接而不是:

echo '<img src="' . get_bloginfo('template_directory') . '/img/icon-trans.png" />'; 
+0

我更新了我的原始帖子,以显示我正在尝试执行的操作。非常感谢您的帮助! –

+0

我仍然无法完成它的任何其他想法?非常感谢... –