I’m trying to make a nav to access all the different galleries on a single page.
Instead of hard-coding all their names out. I was curious if it was possible to make this dynamic and just call all the ID’s of all the galleries, with maybe an exclusionary on the two that are slideshows.
Anyone got any fresh ideas?
All your Galleries are stored a table called
wp_ngg_gallery
in your wordpress database. (For the sake of completeness: nextGen Gallery creates 2 more tables for albums and pictures, respectively)fetches the IDs of all galleries into an array, ordered by ID from 1 to end. Now for excluding the two that are slideshows (the example will assume their IDs are 4 and 25):
What good are the IDs without the galleries’ titles? Also, wouldn’t it be easier to exclude by title? So this
would give you an array of all non-slideshow galleries ordered alphabetically by gallery title. You could also select with a wildcard
*
instead ofgid, title
, then you’d get all columns from the gallery table, which are gid, name, slug, path, title, galdesc, pageid, previewpic, author.The resulting array is obviously meaningless unless you do something with it, such as iterating over it and creating a list of links.
The structure of the resulting array is:
You get the idea.
EDIT: Creating a navigation from the above database query
Assuming that you already have created pages for all galleries from within the NextGen Gallery > Manage Gallery dialog, the following will create a simple navigation from it. The pageid and title columns must have been selected from the databse.
Reading, in case you care:
get_bloginfo()
functionwpdb
classOr more simply:
If anyone needs to add a menu of galleries using a certain album on a certain page can use my code.