2011-12-01 57 views

回答

7

我用這個代碼,而不是和它的工作

<img src="<?php bloginfo('template_directory'); ?>/images/bg.png"></img> 
+0

爲我工作!謝謝 –

0

這是奇怪的目錄。 ..你可以嘗試get_stylesheet_directory()來代替,看看返回的是什麼?

+0

我試過了,它返回localhost/images/bg.png –

6

get_template_directory()返回目錄,但它並沒有呼應它..所以,如果你有迴音使用它,它會工作

<img src="<?php echo get_template_directory(); ?>/images/bg.png"></img> 

但我會建議使用get_template_directory_uri()來代替,因爲上面不會便攜式(窗口使用反斜槓作爲分隔符)

<img src="<?php echo get_template_directory_uri(); ?>/images/bg.png"></img> 
相關問題