WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question

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


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.