Reputation: 520
I'm using this code to get all images uploaded to a page and it's working fine but I'd like to use the image urls for a lightbox function and currently I'm getting an img
object. Is there any way I can get the image url specifically? I'd like to think it's part of an array. Here's the code I'm using:
<?php
$images = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 999 ) );
if ( $images ) {
//looping through the images
foreach ( $images as $attachment_id => $attachment ) {
?>
<li>
<a href="*the_img_url*" data-lightbox="lightbox-1" data-title="<?php echo $attachment->post_excerpt; ?>" ><?php echo wp_get_attachment_image( $attachment_id, 'full' ); ?>
</a>
</li>
<?php
}
}
?>
Thank you.
Upvotes: 0
Views: 871
Reputation: 300
Have you tried
<?php echo wp_get_attachment_url( $attachment_id ); ?>
// $attachment_id is The ID of the desired attachment
Upvotes: 1