Skip to content

Instantly share code, notes, and snippets.

@erkattak
Created May 30, 2011 21:40
Show Gist options
  • Save erkattak/999520 to your computer and use it in GitHub Desktop.
Save erkattak/999520 to your computer and use it in GitHub Desktop.
WordPress - Pull NextGEN Gallery Preview Image using Gallery ID
<?php
$gallery_id = 1; // Use the PODS column, custom post field or however you would get this ID
$results = $wpdb->get_results("SELECT ng.path, np.filename FROM wp_ngg_pictures np, wp_ngg_gallery ng WHERE np.galleryid=ng.gid AND np.galleryid=".$gallery_id." AND np.pid=ng.previewpic",ARRAY_A);
if(!empty($results[0]['path']) && !empty($results[0]['filename'])) :
$imgpath = $results[0]['path'].'/'.$results[0]['filename'];
endif;
?>
@Shine458
Copy link

Well ... I created a github account just to thank you. You're my day's hero :) I've been struggling with trying to customize this WP plugin using reponsive imaging. Guess using BDD is at the end the easiest way to hack those "user friendly" plugins that are pain in the ass to use as a developer.

Thx again, you really helped me tonite

Sebastien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment