Created
January 22, 2015 22:58
-
-
Save rbk/e1bf4b93cd5e9fa665af to your computer and use it in GitHub Desktop.
Overrides NGG shortcode. Example for query.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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