0
votes

Wordpress galleries have a strange way to work, in my opinion. I explain:

  • Wordpress gallery shows in the post ONLY the images that have been uploaded in the current post. If you add in the gallery an image that already was in Media library, it will not be showed!

  • After having create a gallery, if I remove an image from the gallery it will be showed anyway

  • The gallery displays all the images attached to the post (also featured thumbnail and embedded images) although these images were not included in the gallery

I'd call all of this a bug.

The question: Is it possible to show in the post ONLY the images (both the uploaded ones and the ones that already was in Media libray) that are included in the gallery?

Notice: without using the shortcode [gallery exclude="..."] and without uploading the images directly from Media library?

P.S. To display the gallery in the post I'm using this script:

<ul>
<?php $images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID . '&orderby=menu_order&order=ASC');
foreach( $images as $img_id => $img_r ) :
     $thumb = wp_get_attachment_image_src( $img_id, 'thumb', true );
     $full = wp_get_attachment_image_src( $img_id, 'full', true ); ?>
     <li>
        <a href="<?php echo $full[0] ?>">
             <img src="<?php echo $thumb[0] ?>" alt="<?php echo get_the_title( $img_id ) ?>" title="<?php echo get_the_title( $img_id ) ?>">
        </a>
     </li>

<?php endforeach; ?>
</ul>
1

1 Answers

0
votes

That is not a bug, that's just how the gallery works. It will only display images attached to a post, if you want to add an already-uploaded image to the gallery then you'll need to attach the image to the post from the Media menu.

You can use gallery shortcode to display the images or alternatively you can use the codes on http://www.wpcodesnipps.com/display-images-attached-post/ to display the images.