All posts in my site have custom field with nextgen gallery ID. To display gallery I use this code:

$gallery_id = get_post_meta( $post->ID, 'galerijos_id', true); // Get gallery id from custom field data
 if( $gallery_id ){
   echo '<div class="post-gallery">';
   echo nggShowGallery( $gallery_id ); // Display the gallery
   echo '</div>';

How do I get pictures urls by gallery ID? I need url to pass to xml file. Thanks in advance.

2 Answers 2


After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody.

global $nggdb;

$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$gall_ids = $nggdb->get_ids_from_gallery($get_gall_id);
$images = $nggdb->get_gallery($get_gall_id);

foreach ( $gall_ids as $gall_id ) {
echo $images[$gall_id]->imageURL .'<br>';

For me Paulius's answer wasn't working, here is the change that worked

global $nggdb;

$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$img_ids = $nggdb->get_ids_from_gallery($get_gall_id);

foreach ( $img_ids as $img_id ) {
 $img = $nggdb->find_image($img_id);
 echo $img->get_permalink() .'<br>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.