[wp-trac] [WordPress Trac] #55037: get_posts why returning draft post list?

WordPress Trac noreply at wordpress.org
Wed Feb 2 05:51:53 UTC 2022


#55037: get_posts why returning draft post list?
-------------------------------+------------------------------
 Reporter:  sumitsingh         |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  5.9
 Severity:  critical           |  Resolution:
 Keywords:  has-screenshots    |     Focuses:
-------------------------------+------------------------------

Comment (by costdev):

 == Test Report

 === Env
 * Web Server: Apache
 * WordPress: 6.0-alpha-52448-src
 * Browser: Chrome
 * OS: Linux
 * Theme: Twenty Twenty-Two
 * Plugins: None activated

 === Steps to test
 1. Create two posts: One that is published and one that is saved as a
 draft.
 2. Add the contents of the `first_post_ajax()` function (not including
 `function ...`) in the ticket's description to a custom plugin or your
 theme.
 3. Make the following replacements:

 {{{#!php
 $cid = 1; // Uncategorized
 $dates = 'February-2022'; // Or whatever month-year it is for you.
 $pages = 1;
 }}}

 4. Remove the following block:

 {{{#!php
 <div class="skider-img">
     <a href="'.get_the_permalink().'"><img class="img-responsive"
 src="'.$images[0].'" alt=""></a>
 </div>
 }}}

 5. Visit the frontend.

 === Results
 - Expected: The contents of both posts.
 - Actual: The contents of the published post.
 - Result: **Could not reproduce** ❌ The expected and actual values do not
 match.

 === Notes
 - Try disabling all plugins to see if the issue persists.
 - Try switching to a different theme to see if the issue persists.
 - If the issue does not persist, check for filters that may be applied to
 `pre_get_posts` or similar filters that may be causing an issue.
 - Alternatively, add `post_status => 'publish'` to the `$args` array.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55037#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list