WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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 several images attached to each post. I need to generate a gallery, but because it's heavily customized I don't want to use a gallery plugin, nor the gallery short code. It's also situated in a DIV that is totally separated from the post content/title etc. so it has to be stand-alone code in PHP, hard-coded.

Basically if there's a method to retrieve the list of attachments in a URL format.. and then pull in the proper sizes (filename_80X80.jpg or something along those lines - I know the filenames are manipulated after the thumbnail size).

I already have the thumbnail sizes covered using

add_image_size( 'ourwork_full', 589, 315, true );
add_image_size( 'ourwork_thumb', 80, 80, true );

in the funtions.php file of the template.

How can I achieve this? Do I need to use custom WP query? Or is there a function/template tag that I am missing?

share|improve this question
up vote 2 down vote accepted

Query for image attachments would be something like this (taken from Get The Image plugin/extension) with get_children():

$attachments = get_children( array( 
    'post_parent' => $args['post_id'], 
    'post_status' => 'inherit', 
    'post_type' => 'attachment', 
    'post_mime_type' => 'image', 
    'order' => 'ASC', 
    'orderby' => 'menu_order ID' 
) );

Then you can loop through array and retrieve URLs with wp_get_attachment_image_src() which will get you URL and dimensions.

share|improve this answer
Giggity thanks so much!!! – jeffkee Jan 19 '11 at 11:04
Managed to take this and create a custom function just for me.. thanks again, fantastic stuff. – jeffkee Jan 19 '11 at 11:05

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.