2012-09-09 16 views
1

我有他們的板,它工作正常沒有問題。如何在index.php中顯示img

當我嘗試了themplate轉換爲主題WordPress的,我複製所有內容 index.php主題裏面的內容,我得到了下面的代碼:

<ul> 
           <li> 
            <div class="box-1"> 
             <img src="images/page1-img1.jpg" alt="" /> <a href="#">bora-bora</a> 
<span>from $458</span> 
             <p>Praesent vestibulum aenean 
              <br>nonummy hendrerit mauris.</p> 
            </div> 
           </li> 
           <li> 
            <div class="box-1"> 
             <img src="images/page1-img2.jpg" alt="" /> <a href="#">Hawaii</a> 
<span>from $458</span> 
             <p>Praesent vestibulum aenean 
              <br>nonummy hendrerit mauris.</p> 
            </div> 
           </li> 

圖像不顯示在屏幕上。

我可以看到我的主題,網址:HTTP`://127.0.0.1/www/www1/wordpress/Heb/wordpress/

看到IMG我可以用全路徑看:

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme/images/page1-img1.jpg

如果我點擊圖片至極我看不到鼠標右鍵,並複製目標URL,我得到的地址:

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/images/slide-1.jpg 

和錯誤:The requested URL /www/www1/wordpress/Heb/wordpress/images/slide-1.jpg was not found on this server.

我應該在這裏更改<img src="images/page1-img1.jpg" alt="" />以顯示img?

非常感謝。

回答

1

既然你說你的形象的完整路徑是

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme/images/page1-img1.jpg 

,那麼你可以試試這個

<img src="<?php echo get_template_directory_uri()?>/images/yourImageName.png" alt="" /> 

代替

<img src="images/yourImageName.png" alt="" /> 

get_template_directory_uri()將返回你的theme文件夾的路徑,即

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme 
0

如果此圖像是佈局的一部分(而不是內容的一部分),則可以使用整個路徑(例如, http://localhost/image.jpg),或者將其放置在你的主題目錄(比方說,[your theme]/images然後用<img src="<?php bloginfo('template_directory'); ?>/images/image.jpg" alt="">

如果這是你的內容(文章,頁面,無論的一部分),上傳通過WordPress管理文件,並從那裏將它。