Display all albums in nggallery on a page [closed]
IT Nursery
May 22, 2022
0
I’m using the popular NextGen Gallery / nggallery plugin to handle photo albums and galleries on my site.
I can arrange photos into a album and display it using a shortcode no problem, where I’m struggling is that I want to create a master “Photo Galleries” page which will show all of the photo Albums on the site.
Any advice / ideas on how to do this? The only vaguely useful suggestion I’ve found online thus far is to re-arrange the albums so that I have a master albums which has everything else as a sub albums. This feels very suboptimal as each gallery / albums will need to be re-arranged on upload.
I found a duplicate of this question elsewhere on the stack network – https://webmasters.stackexchange.com/questions/1858/how-to-show-all-albums-in-wordpress-nextgen-gallery but that one doesn’t have an answer and hasn’t been migrated to here.
Thanks
Jona
1 Answer 1
I have not a ready solution, but small hints.
You get all albums from nggallery with a small sql select. This get a array with all data to the album. If you have the right fields, change the * and use only the fields, there store your data.
global $wpdb;
$albumlist = $wpdb->get_results("SELECT * FROM $wpdb->nggalbum ORDER BY id");
After this result you can create in a template a list with this data, like the name as example.
Before you play with a sql select please play woth the global var and the functions of nextgen. The important var of ngg is $nggdb. About this you can use many methods to the class of ngg, lik get_used_galleries().
I know about this method. Please check the example source.
global $nggdb;
$galleries = array();
/* find all galleries */
foreach( $nggdb->find_all_galleries() as $gallery ) {
// check the array $gallery
// $gallery: name, path(wp-content), title, previewpicID, author
array_push( $galleries, $gallery->gid );
}
/* create a temporary album with all galleries */
echo nggCreateAlbum( $galleries, 'grid' );