Can anyone convert this gallery code into foreach?

php

#1

$mytheme_gallery_one = get_post_meta( get_the_ID(), 'mytheme_image_one', true );
$mytheme_image_one_image = wp_get_attachment_image( $mytheme_gallery_one, 'large' );
$mytheme_image_one_url = wp_get_attachment_url( $mytheme_gallery_one );

$mytheme_gallery_two = get_post_meta( get_the_ID(), 'mytheme_image_two', true );
$mytheme_image_two_image = wp_get_attachment_image( $mytheme_gallery_two, 'large' );
$mytheme_image_two_url = wp_get_attachment_url( $mytheme_gallery_two );

$mytheme_gallery_three = get_post_meta( get_the_ID(), 'mytheme_image_three', true );
$mytheme_image_three_image = wp_get_attachment_image( $mytheme_gallery_three, 'large' );
$mytheme_image_three_url = wp_get_attachment_url( $mytheme_gallery_three );
?>

<?php echo $mytheme_image_one_image; ?>
<?php echo $mytheme_image_two_image; ?>
<?php echo $mytheme_image_two_image; ?>


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.