diff --git a/src/OowpQuery.php b/src/OowpQuery.php index 37a5aa5..a7d4ffd 100644 --- a/src/OowpQuery.php +++ b/src/OowpQuery.php @@ -29,11 +29,7 @@ function __construct($query = '') // 'attachment' which can cause crashes on ?preview=true if a file title matches a render-able post's. if (!isset($query['post_type']) || (!is_array($query['post_type']) && !array_key_exists($query['post_type'], $wp_post_types))) { - $query['post_type'] = array_values(get_post_types()); - $attachmentTypeIndex = array_search('attachment', $query['post_type'], true); - if ($attachmentTypeIndex !== false) { - array_splice($query['post_type'], $attachmentTypeIndex, 1); - } + $query['post_type'] = array_values(array_diff(get_post_types(), array('attachment'))); } parent::__construct($query);