This is hard to explain but let me try:

  1. Click on add images in the post, select 4 images from media gallery.

  2. The images will show in the post, but will display statically

I would like the 4 images to display in an image gallery.

This is for a hotel website, and I don't want to create a single gallery for EVERY room...

So I would like to be able to add photos per room and have them display as a gallery.

I hope what I'm saying is clear enough...

  • not sure what is actually the question here – Mark Kaplun Oct 6 '16 at 10:11
  • @bruno-vincent Just upload the files, if you use the shortcode gallery all images will be shown. Is not necessary a plugin gallery. There are code to make it looks better. – Fernando Baltazar Oct 7 '16 at 4:17

Dear you can use this plugin that fulfill. Dynamic Featured Images

after install and activate you'll be able to add multiple images in the post. Please use below code to get all images as a gallery.

<?php if( class_exists('Dynamic_Featured_Image') ):
    global $dynamic_featured_image;
    global $post;
    $featured_images = $dynamic_featured_image->get_featured_images( $post->ID );

    if ( $featured_images ):
        foreach( $featured_images as $images ):
            echo '<img src="'.$images['full'].'" alt="">';

Let me know for any assistance.

  • How someone could give us negative marking without any reason? – Faisal Ramzan Aug 10 '17 at 16:47
  • Actually above solution is tested and according to the user requirements. – Faisal Ramzan Aug 10 '17 at 16:48
  • They should make us wrong with their own justifications. – Faisal Ramzan Aug 10 '17 at 17:22

I figured it out.

This can be done with a single module and standard WP functionality.

In the post, click on the left side, there is a create gallery link there.

For them to display more nicely, use the https://wordpress.org/plugins/jquery-colorbox/ plugin.

That's it.

It was so simple stupid that I could not imagine it could be done so easily...so I was fishing for tons of plugins for no reason;)


There are a few different ways you could achieve this.

I recently did it as follows:

  • Activate a simple plugin called 'Media Library Categories'. This lets you assign taxonomy terms to images. You can add a line to your functions.php telling it to create a new taxonomy so it's separate from your other categories.
  • Create a category called 'Gallery'
  • Then instead of inserting the images, you can simply check the 'Gallery' box on each one
  • Insert some code in your template to query for the images and display them in a gallery. I use Wordpress's native gallery feature.

Here's a sample snippet from my code [note - you may want to edit the query/put some logic around it to make sure you get four images]:

$attachments = get_children( array(
    'post_parent' => $post->ID ,
    'post_status' => 'inherit',
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'order' => 'ASC',
    'category_media' => 'gallery',
    'orderby' => 'menu_order'
                ) );
if ( !empty( $attachments ) ):
    $gallery = implode(", ", array_keys($attachments)); 
    echo do_shortcode("[gallery ids='".$gallery."']");

If the photos you want to put in the gallery are the only ones attached to the post, you could skip the plugin part and just output all attached images.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.