Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

NextGen Smooth Gallery:Showing a gallery based on custom field ID WordPress


I have a custom field in my code called 'gallery' which holds the album ID from NextGen Gallery.

What I would like to do is parse that through to NextGen Smooth Gallery so it'll display the gallery alongside the post.

I have the following at the top:
<?php $gallery = get_post_meta($post->ID, 'gallery', true); ?>

And I've been trying to call it using:
<?php echo do_shortcode("[smooth=id:$gallery;]"); ?>

But all it does is show [smooth=id$3]. (3 being the ID)

What am I doing wrong?

Just uploaded the source code to [[LINK href=""]][[/LINK]] and you can view it at [[LINK href=""]][[/LINK]]

Answers (3)


Cristian Antohe answers:

This doesn't work because what you put in your post ( [smooth=id:yyy;] ) isn't a shortcode.

It's just a filter on the_content :)

Just make a custom loop using wp_query where you want to display your gallery and insert just the one page that has [smooth=id:yyy;] in it. After that exclude that page from the menu and you should be set... sort of...

Or just use a different gallery plugin for nextgen: It can be modified quite a lot ( it's based on )


Dan Fraticiu answers:

I can't get this plugin working (keeps saying it only works with NextGen Gallery - which I have instaled), so I can't test the code.

I looked through the code and like Cristian said it adds a function to the content filter, so I thing this should work:

$gallery = get_post_meta($post->ID, 'gallery', true); ?>

echo apply_filters( "the_content", '[smooth=id:$gallery;]' );

Later Edit: a bit of update, a check to be sure if the $gallery is set.


kjll kll answers:

This should work (hope so). Give it a try...

<!-- Get the post meta gallery Id -->

<?php $cf_getGalleryId = get_post_meta($post->ID, 'gallery', true); ?>

<!-- Check if it relly does exist -->

<?php if ($cf_getGalleryId != Null) : ?>

<!-- Execute the shortcode for that gallery Id -->

<?php echo do_shortcode('[smooth=id:' . $cf_getGalleryId . ';]') ; ?>

<?php endif; ?>