[wp-hackers] Reusing queries

Jeremy Clarke jer at simianuprising.com
Sun Nov 14 19:00:52 UTC 2010


I might be missing something but couldn't you do something more like

$post_images =
get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image");

if (is_array($post_images) and count($post_images)) :
  foreach ($post_images as $id => $details) :
        // VALIDATE THE IMAGE THEN DO WHAT YOU WANT WITH IT.
  endforeach;
endif;

I'm pretty sure the results from get_children() will give you access to the
data you need about the images, and you'd only have to do the one query to
get all the data. You might end up with some extras for postmeta or
something, but you would probably have had those extra queries with your
other system anyway.



-- 
Jeremy Clarke | http://jeremyclarke.org
Code and Design | http://globalvoicesonline.org


More information about the wp-hackers mailing list