Title: Multiple specific posts using wp_query and post__in array &#8211; EXPLAINED
Last modified: August 20, 2016

---

# Multiple specific posts using wp_query and post__in array – EXPLAINED

 *  Resolved [ixwa](https://wordpress.org/support/users/ixwa/)
 * (@ixwa)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/multiple-specific-posts-using-wp_query-and-post_in-array-explained/)
 * This is a placeholder solution snippet for anyone who encountered the same problem
   I did.
 * This DOES NOT work:
 *     ```
       function doProduct($allTypes) {
       //Where $allTypes is a string "1, 2, 3, 4"
   
       $args = array(
       'post_type' => 'product',
       'categories'	=> 'misc',
       'post_status' =>	'publish',
       'post__in' => array($allTypes)
       );
   
       ...
       }
       ```
   
 * So even though $allTypes is a literal string “1, 2, 3, 4” that would look EXACTLY
   like what you might have typed into the array yourself, it doesn’t work.
 * This DOES work:
 *     ```
       function doProduct($allTypes) {
       //Where $allTypes is a string "1, 2, 3, 4"
   
       $args = array(
       'post_type' => 'product',
       'categories'	=> 'misc',
       'post_status' =>	'publish',
       'post__in' => explode(',', $allTypes)
       );
   
       ...
       }
       ```
   
 * Don’t ask me why. Another reason why WordPress is more like KlugePress…or maybe
   it’s just screwy PHP.

The topic ‘Multiple specific posts using wp_query and post__in array – EXPLAINED’
is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [comma](https://wordpress.org/support/topic-tag/comma/)
 * [explode](https://wordpress.org/support/topic-tag/explode/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [implode](https://wordpress.org/support/topic-tag/implode/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [post__in](https://wordpress.org/support/topic-tag/post__in/)
 * [string](https://wordpress.org/support/topic-tag/string/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [ixwa](https://wordpress.org/support/users/ixwa/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/multiple-specific-posts-using-wp_query-and-post_in-array-explained/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
