Post emergency WordPress questions for fast help... ...Or answer questions first & win prize money.

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

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 http://pastebin.com/m59df2a28 and you can view it at http://wordpress.geek.nz/logan/test/

Matt Hancock | 02/05/10 at 12:08am | RSS Answers | Tags

(3) Possible Answers Submitted...

  • avatar
    Last edited:
    02/05/10
    4:01pm
    Cristian Antohe says:

    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:
    http://www.cozmoslabs.com/2010/01/13/wordpress-photo-slideshow/ It can be modified quite a lot ( it's based on http://spaceforaname.com/galleryview )

  • avatar
    Last edited:
    02/05/10
    2:08pm
    Dan Fraticiu says:

    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:


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

    if($gallery){
    echo apply_filters( "the_content", '[smooth=id:$gallery;]' );
    }
    ?>


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

  • avatar
    Last edited:
    02/05/10
    11:33am
    Christian Kobben says:

    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; ?>

This question has expired.