[wp-hackers] query_posts behaviour

Jon Mihkkal Inga lilla.molnet at gmail.com
Tue Jan 27 15:53:17 GMT 2009

Hello! I'm new here so please be gentle :)
I've noticed something about the the query_posts function. It doesn't do
anything if I set 'post_type' to 'attachment'. I would expect it to setup
all attachments so that they are available in the loop. Is this the intended
There are plenty of reasons this is desireable. For one I am building a
section to display images uploaded to a photoblogg, and being able to use
the loop and other template tags as well as the entire paginating system
would save a lot of code and make for easy tweaking.

I haven't been able to figure out exactly how to fix this, though my guess
is that setting post_type='attachment' will cause is_attachment() or
is_single() to return true and that relevant query variables are then
filtered out at some point.
Ticket #8872 http://trac.wordpress.org/ticket/8872
seem somewhat related but doesn't fix the 'attachment' case. All 'any' post
type does is include pages to the query, as I understand.

Any pointers would be greatly appreciated. Thank you for your time :)


More information about the wp-hackers mailing list