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

Eric Mann eric at eamann.com
Wed Jan 20 16:06:07 UTC 2010


Can you give us a link to a postbin containing your code?  That will make it
easier to help you adjust your query.

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Adam Holzband
Sent: Wednesday, January 20, 2010 2:04 AM
To: wp-hackers at lists.automattic.com
Subject: [wp-hackers] Query to return only posts that have an image
attachment

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.
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list