I want to get a list of galleries of a certain album. Than I would create a link to this galleries. How do I get the list of galleries in PHP?

I saw that there is some code like

global $nggdb;
$gallery = $nggdb->get_gallery ($galleryID, 'sortorder', 'ASC', true, 0, 0);

but is there some documentation which functions I could use?


Put this into your page template:

    global $nggdb;
    $galleries = array();

    $album = $nggdb->find_album(1);

    foreach( $album->gallery_ids as $galleryid ){
        $gallery = $nggdb->find_gallery($galleryid);
        $galleries[$galleryid]['title'] = $gallery->title;
        $galleries[$galleryid]['url'] = get_bloginfo('url') . '/portfolio/?album=all&gallery=' . $galleryid;

    foreach($galleries as $category){
        echo '<a href="' . $category['url'] . '">' . $category['title'] . '</a><br />';

You have to adapt the album id and you need to link to a page where the album code of NGG is active.

All functions can be found in /wp-content/plugins/nextgen-gallery/lib/ngg-db.php.

| improve this answer | |
  • how do you link to a page where the album code of NGG is active, can you do a little explain? – Murhaf Sousli Jun 9 '14 at 0:46
  • On the portfolio page (page with overview over all galleries) I had [album id=1 template=portfolio]. The rest were galleries created with NGG. The links looks like http://yourdomain.com/portfolio/?album=1&gallery=2. I also created pages (page for one gallery) with the code like [nggallery id=1] but I didn't used the page - only I retrieved the content. Thats what I remember. – testing Jun 12 '14 at 19:31

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