Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#39682 closed enhancement (duplicate)

WP_Query: Small fix for 'post__in' argument showing all results if empty array is passed

Reported by: edonramadani Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Query Keywords:
Focuses: Cc:


When an empty array is passed to


it should return no results instead of all posts.
File: wp-includes/class-wp-query.php @line 1956

} elseif ( $q['post__in'] ) {
    if(count($q['posts__in']) > 0){
        $post__in = implode(',', array_map( 'absint', $q['post__in'] ));
    } else {
        $post__in = NULL;
    $where .= " AND {$wpdb->posts}.ID IN ($post__in)";

Change History (3)

#1 @edonramadani
5 years ago

  • Keywords needs-testing added

#2 @swissspidy
5 years ago

  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hey there,

Welcome to WordPress Trac! This was previously reported in #28099 and #12212 and it was decided to not change this behaviour because of backward compatibility concerns.

#3 @edonramadani
5 years ago

Hello there,

Thank you for your reply, and thank you for welcoming me to WordPress Trac!
I did not see the decision to not change this because of backward compatibility concerns, I apologize.

Note: See TracTickets for help on using tickets.