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

git-svn-id: http://svn.automattic.com/wordpress/trunk@14419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-05-03 22:22:34 +00:00
parent 248f4ab860
commit 02c300164a
1 changed files with 4 additions and 3 deletions

View File

@ -2160,8 +2160,9 @@ class WP_Query {
} }
$exclude_post_types = ''; $exclude_post_types = '';
foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type ) $in_search_post_types = get_post_types( array('exclude_from_search' => false) );
$exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $_wp_post_type); if ( ! empty( $in_search_post_types ) )
$exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type IN ('" . join("', '", $in_search_post_types ) . "')");
if ( 'any' == $post_type ) { if ( 'any' == $post_type ) {
$where .= $exclude_post_types; $where .= $exclude_post_types;