[wp-trac] [WordPress Trac] #44737: WP_Query: in searches post_status should consider exclude_from_search

WordPress Trac noreply at wordpress.org
Sun Aug 5 22:53:44 UTC 2018


#44737: WP_Query: in searches post_status should consider exclude_from_search
--------------------------+-----------------------------
 Reporter:  felipeelia    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 When `post_status` is empty and we are running a search, this code is
 executed (wp-includes/class-wp-query.php:2446):

 {{{#!php
 // Add public states.
 $public_states = get_post_stati( array( 'public' => true ) );
 foreach ( (array) $public_states as $state ) {
         if ( 'publish' == $state ) { // Publish is hard-coded above.
                 continue;
         }
         $where .= " OR {$wpdb->posts}.post_status = '$state'";
 }
 }}}


 That way the `exclude_from_search` parameter isn't considered.

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


More information about the wp-trac mailing list