Make WordPress Core

Changeset 14419


Ignore:
Timestamp:
05/03/2010 10:22:34 PM (15 years ago)
Author:
ryan
Message:

White list instead of black list post types when searching. Props sivel. fixes #13183

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r14404 r14419  
    21612161
    21622162        $exclude_post_types = '';
    2163         foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type )
    2164             $exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $_wp_post_type);
     2163        $in_search_post_types = get_post_types( array('exclude_from_search' => false) );
     2164        if ( ! empty( $in_search_post_types ) )
     2165            $exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')");
    21652166
    21662167        if ( 'any' == $post_type ) {
Note: See TracChangeset for help on using the changeset viewer.