WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Scenario: I have an album with 5 galleries. Each gallery contains between 10 & 25 images. I have a 'Gallery' page on my WP site and using the shortcode [album id=7 template=extend], which contains all 5 galleries. Each individual gallery is also posted to a particular post/page using the shortcode [nggallery id=4].

Request: Client wants to keep the Gallery page as is, with all galleries, and their images, visible. The request is that they only want a select few, e.g. the best 5, from each gallery to be displayed on each of the posts/pages with individual galleries.

Can this be done? Would it be best to create custom shortcodes for this or has anyone come across this possibility yet?

Tags seems to be the simplest method up to this point, after finding this article

I have set my tags as "hero" but this does not appear to be limited to any gallery. I am using the shortcode [nggtags id=1 gallery=hero] where the ID would change per gallery.

Is there a way I can use this method, perhaps, without using alternate tags to determine which images are displayed?

Any help on this would be much appreciated. Thanks.

share|improve this question

closed as off-topic by Mark Kaplun, Johannes Pille, birgire, Pieter Goosen, s_ha_dum Oct 8 '14 at 21: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, Johannes Pille, birgire, Pieter Goosen, s_ha_dum
If this question can be reworded to fit the rules in the help center, please edit the question.

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.

share|improve this answer

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