Is there any possibility on WordPress to get an image from a post gallery?
Images are not inserted in the post, are on it’s gallery.
I’m trying to do a “galleries index” page and instead having the user set a “cover image” I’d like to take any of the attached to the post as part of a gallery.
I tried the wp_get_attachment_image() with no luck, I think because it works for inserted images, not the ones on it’s gallery.
Thanks in advance.
Juan.-
You can get the attached media to a post using get_children. IE: get the first attached image for post ID == 14
I hate suggesting plug-ins as an answer, but have you checked out Justin Tadlock’s get the image plug-in? Worth dissecting for sure, great for learning, and it could definately help you with your problem.
http://wordpress.org/extend/plugins/get-the-image/
If you want to use native wordpress functions, just check out the codex.
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image