Skip to content

Instantly share code, notes, and snippets.

@rbk
Created January 22, 2015 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbk/e1bf4b93cd5e9fa665af to your computer and use it in GitHub Desktop.
Save rbk/e1bf4b93cd5e9fa665af to your computer and use it in GitHub Desktop.
Overrides NGG shortcode. Example for query.
function gurustu_slideshow_override( $atts, $content = null ) {
global $wpdb;
$atts = shortcode_atts( array(
'id' => '0',
), $atts );
if( $atts['id'] ){
$gallery = 'SELECT title, path FROM wp_ngg_gallery WHERE gid = '. $atts['id'] .';';
$pictures = 'SELECT description, filename FROM wp_ngg_pictures WHERE galleryid = '. $atts['id'].';';
$gallery = $wpdb->get_results($gallery);
$pictures = $wpdb->get_results($pictures);
ob_start();
// print_r( $gallery );
// print_r( $pictures );
?>
<div class="clear"></div>
<div class="inline-slideshow-wrap">
<ul class="rs-slideshow">
<?php foreach( $pictures as $pic ) : ?>
<?php
$file = get_site_url() . '/' . $gallery[0]->path . '/' . $pic->filename;
?>
<li><a href="<?php echo $file; ?>" rel="lightbox[<?php echo $gallery[0]->gid; ?>]"><img src="<?php echo $file; ?>" alt="<?php echo $pic->description; ?>"></a></li>
<?php endforeach; ?>
</ul>
<div class="inline-slideshow-nav">
</div>
</div>
<?php
}
return ob_get_clean();
}
add_shortcode( 'slideshow', 'gurustu_slideshow_override' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment