Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been wondering about this image/gallery issue for ages.

So, I've got some images:

lifestyle1.jpg, lifestyle2.jpg, lifestyle3.jpg, lifestyle4.jpg, kids1.jpg, kids2.jpg, kids3.jpg, outdoors1.jpg, outdoors2.jpg, etc....

I want to have three galleries:

  1. Homepage —a mixture of all photos
  2. Lifestyle —just lifestyle
  3. Outdoors — just outdoors
  4. Kids— just kids

I can obviously make a page called Lifestyle, attach the lifestyles images and I'm all set with my Lifestyle gallery.

How do I make my Homepage gallery a mixture of all pictures? ie:

Homepage - lifestyle1.jpg, lifestyle2.jpg, kids2.jpg, outdoors1.jpg

When all these photos are already in the media library. It seems so basic, yet I can't see a way to do it besides re-attaching and re-uploading the same images again.

Thanks!

share|improve this question

1 Answer 1

If you open wp-includes/media.php file you will see such code in gallery_shortcode function:

...
if ( !empty($include) ) {
    $include = preg_replace( '/[^0-9,]+/', '', $include );
    $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
    ...
}
...

It means that you can use gallery shortcode with include attribute, where you can insert ids of all images which you require for gallery:

[gallery include="45,59,61,62"]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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