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 have uploaded images before in my other posts and now I want to display it in my Photo Gallery. I'm using an isotope layout so I'm not using the native gallery of WordPress. It's working just fine however I can't display the images that is not uploaded directly to that post. For example the images that I've uploaded before. If I upload a new one to this current post, then that will display.

Here's my code:

        $attachments = get_children(array('post_parent' => $post->ID,
          'post_status' => 'inherit',
          'post_type' => 'attachment',
          'post_mime_type' => 'image',
          'order' => 'ASC',
          'orderby' => 'menu_order ID'));
        foreach($attachments as $att_id => $attachment) {

So how can I display those past images in my gallery?

share|improve this question
Please clarify what images you want to retrieve. What do you mean by "images that I've uploaded before" and "past images in my gallery"? – s_ha_dum Jul 11 '13 at 14:34

Changing 'post_parent' => $post->ID to 'post_parent' => null will fetch all images.

share|improve this answer
It is not clear the OP wants "all images". There seems to be a condition for images in a "parent gallery" or "past images in my gallery". – s_ha_dum Jul 11 '13 at 14:22
I see...I have uploaded images before in my other posts could mean, that he want's to get images which have been attached to any post in the past only without images, which are not attached to a post. I edit my answer as soon as we get more information. – rfrq Jul 11 '13 at 14:32
I don't think you are wrong, necessarily, but the question isn't clear. – s_ha_dum Jul 11 '13 at 14:33

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.