0
我創建了一個自定義的帖子類型,其中包含一個圖片庫上傳。現在我正試圖在前端顯示畫廊。這是我迄今爲止能夠顯示1張圖片的功能,但是如果上傳多張圖片,所有網址都會卡在src標籤中。所以我猜我應該循環遍歷這個數組並且分別吐出每一個?那是否會成爲一條路呢?如果是的話,我該如何做到這一點?任何幫助表示讚賞。在Wordpress中循環訪問數組
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
echo '<img src="'.get_post_meta($post->ID, 'gallery-upload', true).'">';
?>
<?php endwhile; else: ?>
<p><?php _e('No posts were found. Sorry!'); ?></p>
<?php endif; ?>
編輯:
這是正在返回什麼:
<img src="http%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F800x400-volbeat-mock1.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F1574_2_1.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F1576_2_1.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F1576_4_1.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F2244_2_1.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F300789_2349086884438_1168050047_32154880_1451576942_n.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F373795_278881222158106_278880528824842_834930_1454244548_n.jpeg%2Chttp%3A%2F%2Flocalhost%3A8888%2Fandreasmoulis%2Fwp-content%2Fuploads%2F2012%2F10%2F20110909-121141.jpeg">
我會玩它,謝謝。看看我的編輯,這就是我的代碼。任何想法爲什麼? – souporserious
嘿,哎呀。刪除rawurlencode(...)函數(請參閱上面的更新),它應該修復它。 – adamdunson
仍然沒有任何東西,它將所有內容都返回
因此,它會生成所有鏈接。只是不在單獨的圖像標籤。 –
souporserious