certainlyakey
3/3/2014 - 12:32 PM

Wordpress - custom gallery from WP post gallery

Wordpress - custom gallery from WP post gallery

<?php 
$args = array(
	'numberposts' => -1, // Using -1 loads all posts  
	'orderby' => 'menu_order', // This ensures images are in the order set in the page media manager  
	'order'=> 'ASC',  
	'post_mime_type' => 'image', // Make sure it doesn't pull other resources, like videos  
	'post_parent' => $post->ID, // Important part - ensures the associated images are loaded 
	'post_status' => null, 
	'post_type' => 'attachment'
);

$images = get_children( $args );
// Starkers_Utilities::print_a($images);
if ($images) { ?>  
<ul class="gallery">  
	<?php foreach($images as $image){ 
		$imgsrc = wp_get_attachment_image_src( $image->ID, 'medium');
		// array_push($imgsrc, $imgsrcarr[0]);
		?>
	<li><figure class="gallery-item">
		<img src="<?php echo $imgsrc[0]; ?>" alt="<?php echo $image->post_title; ?>" title="<?php echo $image->post_title; ?>">
	</figure></li>
	<?php } ?>  
</ul>
<?php } ?>