[wp-trac] [WordPress Trac] #55207: WP_Query returns published sticky posts when post_status is set to draft

WordPress Trac noreply at wordpress.org
Sun Feb 20 14:06:52 UTC 2022


#55207: WP_Query returns published sticky posts when post_status is set to draft
--------------------------+-----------------------------
 Reporter:  NomNom99      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  5.9
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Originally reported here - [https://github.com/wp-cli/entity-
 command/issues/278]

 **Error:**
 If a sticky post is published, the following query returns the published
 sticky post:


 {{{
 <?php
 <?php
 $query = new WP_Query( array(
     'post_status' => 'draft',
 ) );
 ?>
 ?>
 }}}

 Steps to reproduce:

 1. Create a sticky post and publish it
 2. Create a WP_Query with its 'post_status' set to 'draft'
 3. Run the query
 4. Observe that the published sticky post is returned

 **Expected behaviour:**
 Setting `post_status` to `draft` should not return published sticky posts.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55207>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list