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?

  • 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.

  • 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 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.