I need to get the list of images added in a gallery
-
I have a custom post type named “services” and there I have a wysiwyg field (called galeria), created with the “advanced custom field” plugin.
In that field, the user adds a gallery with images.And i have a code to get the images from that gallery to use it on different places.
What i need is to change the code a little so it works with wordpress 4.1, in other versions it used to work just fine. Now the first picture never appears.This is the code:
<?php remove_shortcode('gallery'); $gallery_content = get_field('galeria', $post->ID); preg_match('/\[gallery.*ids=.(.*).\]/', $gallery_content, $ids); $image_ids = explode(",", $ids[1]); $count = 0; $max = 9999; // define how many images to show foreach($image_ids as $image_id) { $count++; if ($count > $max) { break; } $imagebig = wp_get_attachment_image_src( $image_id, 'large', false, '' ); $imagethumb = wp_get_attachment_image_src( $image_id, 'thumb-size', false, '' ); $imageslider = wp_get_attachment_image_src( $image_id, 'slider-size', false, '' ); $alt = get_post_meta($image, '_wp_attachment_image_alt', true); echo '<li><img src="'.$imageslider[0].'"';?> alt="" ></li> <?php } ?>
- The topic ‘I need to get the list of images added in a gallery’ is closed to new replies.