NextGEN Gallery preview / Show specific images [closed]

I believe I had a situation that can relate to yours. I had hijacked NextGen Gallery’s ‘Exclude’ checkbox to show ‘new’ pictures. I figured this would be the best way, given that I didn’t want to completely rewrite everything with the plugin that could break in the future.

(This part may not apply to you) but I wrote a template with the use of the ‘Advanced Custom Fields’ plugin to include the gallery number. That way, I could use my own template and perform a custom query to the database to pull all the images based on the nextgen gallery’s ID that was entered in the page.

This worked great, then the client wanted to show only the ‘New’ pictures from all the galleries in one page. This is the end result I came up with:

$image_query = ' SELECT '. $wpdb->prefix .'ngg_pictures.*, '. $wpdb->prefix .'ngg_gallery.path FROM '. $wpdb->prefix .'ngg_pictures LEFT JOIN '. $wpdb->prefix .'ngg_gallery ON '. $wpdb->prefix .'ngg_pictures.galleryid = '. $wpdb->prefix .'ngg_gallery.gid WHERE '. $wpdb->prefix .'ngg_pictures.exclude = 1 ORDER BY '. $wpdb->prefix .'ngg_pictures.sortorder';

As I said, I hijacked the functionality of the ‘exclude’, so this says to get all the pictures from the ngg_pictures table and the path (so I could include the path to the image to display it and make an anchor tag) from each gallery, at the specific gallery id, where exclude = 1.

//Now run it!
$images = $wpdb->get_results($image_query);
if ($images) {  

Then I throw this into a foreach and pull out what I need.

Like I said, this can relate to yours, where this uses the exclude instead of the tags. I bring this up because where you are only using one tag, and trying to search based on that tag, this might be an alternative for you.