How can I achieve two things with the existing code below:
- Remove the null values, as these are exporting bxslider items that have broken links
For some reason two versions of each image in the the pager are showing. Can anyone see why and how i stop these duplicates.
<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>
First, you can run array_filter() on the $ar array to remove false/ empty values.
Next, you probably don't need this line
You could comment it out and it won't have any effect on the page.