Find attachments by multiple post/page ids (1 post)

  1. Parakoos
    Posted 4 years 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_mime_type' =>'image',
    		'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!


Topic Closed

This topic has been closed to new replies.

About this Topic