0
我如何能實現與下面的現有代碼兩件事情:Bxslider,自定義字段和WordPress的
- 取出空值,因爲這些是出口bxslider已斷開鏈接
出於某種原因,兩個項目正在顯示尋呼機中每個圖像的版本。任何人都可以看到爲什麼以及我如何阻止這些重複。
<ul class="bxslider"> <?php $images = get_post_meta(get_the_ID() , "images", true); $images = unserialize($images); // Read into array foreach($images as $image) { $ar[] = array( "order" => $image['order'], "img_id" => $image['image_id'], "desc" => $image["desc"] ); } // Sort array by order asort($ar); // Output data for Galleria foreach($ar as $item) { $image_id = $item['img_id']; $media_med = wp_get_attachment_image_src($image_id, "medium", false); $media_full = wp_get_attachment_image_src($image_id, "full", false); echo "<li><img data-title='" . $item["desc"] . "' data-big='" . $media_full[0] . "' src='" . $media_med[0] . "'></li>"; } ?> </ul> <div id="bx-pager"> <?php $images = get_post_meta(get_the_ID() , "images", true); $images = unserialize($images); // Read into array foreach($images as $image) { $ar[] = array( "order" => $image['order'], "img_id" => $image['image_id'], "desc" => $image["desc"] ); } // Sort array by order asort($ar); // Output data for Galleria foreach($ar as $item) { $image_id = $item['img_id']; $media_med = wp_get_attachment_image_src($image_id, "medium", false); $media_full = wp_get_attachment_image_src($image_id, "full", false); echo "<a href='' data-slide-index='0'>"; echo "<img src='" . $media_med[0] . "'>"; echo "</a>"; } ?> </div>
感謝您的支持。我對array_filter沒有任何經驗 - 你能在我的代碼的ocntext中包含一個例子嗎? – dmt
就在排序數組之前。 array_filter($ ar); asort($ ar); – DoctorFox