[wp-trac] [WordPress Trac] #28099: Empty array passed to WP_Query post__in returns posts

WordPress Trac noreply at wordpress.org
Wed Mar 18 18:59:12 UTC 2015

#28099: Empty array passed to WP_Query post__in returns posts
 Reporter:  danielbachhuber  |       Owner:  wonderboymusic
     Type:  enhancement      |      Status:  reopened
 Priority:  normal           |   Milestone:
Component:  Query            |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:
Changes (by maksbd19):

 * status:  closed => reopened
 * type:  defect (bug) => enhancement
 * resolution:  wontfix =>


 I had to developed a plugin that requires querying posts based on their
 linked posts. I could not find a way to use WP_Query class to take care of
 this, so I queried for the matched posts separately and passed the matched
 ones in the WP_Query object. I know I should check matched ids are present
 before the query but in case of a filter like "pre_get_posts" I had no
 option but to trick the query_var parameter so that it can never find any
 post based on provided case. I achieved my result but I strongly believe
 that there should be a nicer way to achieve the same result than this
 ridiculously ugly hack.

 I request to the community and the experts for a separate class for this
 parameter may be like WP_Meta_Query so that the query class could be used
 in even more complicated and advanced cases.

Ticket URL: <https://core.trac.wordpress.org/ticket/28099#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list