Nextgen code for page template using gallery_id & post_meta
-
I have a nextgen slideshow gallery appearing on each post to display the post gallery. Each post has a custom field (carousel_ngen_gallery) that refers to a nextgen gallery which seem to be the same as the gallery_id field. At the bottom of the page I just want to display all the thumbnails of the pictures in the gallery for printing etc – in addition to the slideshow which appears at the top.
I have written two different functions for functions.php to automatically show the gallery at the bottom of the post by using the custom field gallery_ id see below. Neither of them work though. I have clearly done something stupid but I am not sure what. Anyone got any ideas?
Option 1. This one is only showing the post thumbnail and nothing else and the thumbnail url is not refering to the gallery directory at all.
add_action('pagelines_loop_after_post_content', 'autogallerycube'); function autogallerycube(){ if( is_single($post)) { $gallery = get_post_meta($post->ID, 'carousel_ngen_gallery', true); $gal = $gallery; $gal = apply_filters('the_content', '[gallery='.$gal.']' ); echo $gal; } }
Option 2. This one displays this [Gallery not found.
add_action('pagelines_loop_after_post_content', 'autogallerycube'); function autogallerycube(){ if( is_single($post)) { $gallery_id = get_post_meta( $post->ID, 'gallery_id', true); if( isset($gallery_id) ){ echo "<div class=\"post-gallery\">"; echo nggShowGallery( $gallery_id ); echo "</div>"; } } }
But if I overwrite
echo nggShowGallery( $gallery_id ); with echo nggShowGallery( 4 );
It shows what I want – gallery 4 as thumbnails. So I have done something wrong when trying to recall the post_meta.
Anyone see the error of my ways!
- The topic ‘Nextgen code for page template using gallery_id & post_meta’ is closed to new replies.