Skip to content

Commit

Permalink
Merge pull request #20 from outlandishideas/19-exc-attachments
Browse files Browse the repository at this point in the history
Exclude attachments from `OowpQuery`
  • Loading branch information
rasmuswinter authored Jul 14, 2021
2 parents fd04991 + 809a7ac commit a41bec8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/OowpQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ function __construct($query = '')
);
$query = wp_parse_args($query, $defaults);

// if there is no post type, or the post type is singular and isn't valid, replace it with 'any'
// If there is no post type, or the post type is singular and isn't valid, replace it with any *except*
// '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'] = 'any';
$query['post_type'] = array_values(array_diff(get_post_types(), array('attachment')));
}

parent::__construct($query);
Expand Down

0 comments on commit a41bec8

Please sign in to comment.