• I am building up a portfolio using wordpress and I would like to add screenshots using the gallery, but in a way so I can hardcode it into the post template rather than adding a gallery tag in the post itself. I would like to use custom fields to add a gallery id so that I can set the correct gallery for each post/projekt.

    Any pointers as to how to make this?

Viewing 1 replies (of 1 total)
  • Thread Starter Jimi Wikman

    (@mortfiles)

    Found the solution ??

    <?php
       $meta_id = $wp_query->post->ID; /* stores your post id in a variable */
    
    /* This stores the defined gallery ID into a variable.  Setting this to true makes sure it returns a string instead of an array */
       $meta_gallery_id = get_post_meta( $meta_id, 'meta_gallery_id', true );
       if( $meta_gallery_id != '' ) {
    	   $meta_gallery = '[gallery=' . $meta_gallery_id . ']';
    	   $meta_gallery= apply_filters( 'the_content', $meta_gallery );
    	   echo $meta_gallery;
    	 }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: NextGEN Gallery] Using galleries with custom fields?’ is closed to new replies.