Support » How-To and Troubleshooting » Find attachments by multiple post/page ids
4 years, 3 months ago
I want to get the attachments of a user-driven query. They can for example specify categories to include/exclude, tags to include/exclude and whether to include pages or not.
I’m breaking this up in two sections.
1. Search for and collate an array of page/post IDs to include.
2. Feed this array into my query for attachments.
It is this second part that I am having a hard time with. I have the following query:
$iw_query = new WP_Query( array(
'post_type' => 'attachment',
'post_status' => 'all',
'post_parent' => array(8,1)
Now, if I set ‘post_parent’ to a single integer, it works, but it doesn’t accept a list of IDs, either as a string or array.
Is there an alternative way of doing this?
Many thanks for any help!