Grow your CSS skills. Land your dream job.

Get array of Images from a WordPress Post

  • # February 27, 2012 at 2:26 pm

    In the wordpress loop, I’m trying to get an array of images that are used in a blog post but Google has only been showing me old answers that aren’t compatible anymore

    # February 27, 2012 at 2:33 pm

    http://codex.wordpress.org/Function_Reference/wp_get_attachment_image

    The first example should be what you’re looking for.

    # February 27, 2012 at 3:04 pm

    @Kermet, thanks for the link. That helped me solved what the real issue was. It’s not counting the images in the post as attachments. When you insert an image into a post, it adds it to that posts’ media gallery. The post I was testing this on was only showing one image in it’s media gallery even after I attached more images. Other posts with more images in their media gallery are showing more images.

    Do you know why this is?

    # February 27, 2012 at 3:07 pm

    Yeah, with a bit more testing. Only images uploaded to that specific post are showing up as attachments. Images uploaded to other posts arent counted.

    What I’m looking for is an array of images that are actually inserted into the post, and not necessarily uploaded to that specific post.

    # February 27, 2012 at 4:05 pm

    I use attachments plugin (http://wordpress.org/extend/plugins/attachments/) to attach media to a post, then i can retrieve all the attached media as an array.
    You could try that if wordpress’ get_attachment function doesn’t do the trick for you

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".