[wp-hackers] Query to return only posts that have an image attachment

Adam Holzband adamholz at gmail.com
Wed Jan 20 10:04:02 UTC 2010


Hello all...

I am hoping for some guidance on a query:  I have a category template with a
normal loop.  Inside the loop, I run get_children to determine if the post
has an image attachment - if it does, I display it and if not the loop moves
on to the next post.  I would like to adjust the template to query only
posts containing an attachment so that the page displays the full count of
posts per page.  What is the best way to accomplish this, and if it's
adjusting the SQL what's the most efficient query?

Thanks for your help.


More information about the wp-hackers mailing list