1

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?

closed as off-topic by Mark Kaplun, Pieter Goosen, birgire, Johannes Pille, gmazzap Sep 20 '14 at 23:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, Pieter Goosen, birgire, Johannes Pille, gmazzap
If this question can be reworded to fit the rules in the help center, please edit the question.

8

Put this into your page template:

<?php
    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.

  • 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.