[wp-trac] [WordPress Trac] #27674: WP_Query auto-draft
    WordPress Trac 
    noreply at wordpress.org
       
    Mon Apr  7 07:01:14 UTC 2014
    
    
  
#27674: WP_Query auto-draft
--------------------------+------------------------------
 Reporter:  Philo01       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  3.8.1
 Severity:  normal        |  Resolution:
 Keywords:  2nd-opinion   |     Focuses:
--------------------------+------------------------------
Changes (by Philo01):
 * keywords:  close => 2nd-opinion
Comment:
 Thanks for your reply.
 I know the results are different, after the WP_Query I would fetch the
 post from the results.
 Anyway I still feel this is a bug, so I made a small screencast to show
 it: http://d.pr/v/aRY6
 Code:
 {{{
 <?php
 $post_id = (isset($_GET['post-id'])) ? $_GET['post-id'] : false;
 if($post_id)
 {
         $post = new WP_Query( 'p=' . $post_id .
 '&post_type=post&post_status=auto-draft' );
         echo '<h3>WP_Query:</h3><hr>';
         var_dump($post);
 }
 else
 {
         require_once( ABSPATH . 'wp-admin/includes/post.php' );
         $post = get_default_post_to_edit( 'post', true );
         echo '<h3>get_default_post_to_edit:</h3>';
         echo '<a href="?post-id=' . $post->ID . '">Post ' . $post->ID .
 '</a><hr>';
         var_dump($post);
 }
 ?>
 }}}
 As you can see the WP_Query returns 0 posts, while the raw query returns 1
 post.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27674#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list