I have a custom post type for events. A couple of days after each event photos are sometimes uploaded and attached to the event they were taken at.
I want to highlight these image gallerys somewhere on my site, displaying them under a headline “Recently Changed Image Galleries”.
How can I query posts of type ‘event’ that have 3 or more image attachments, and order the result by the upload or publish time of the newest attachment?
This should do it for you.
If you’re calling it in a function, you’ll of course need to ensure
$wpdb
is the global.