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

git-svn-id: https://develop.svn.wordpress.org/trunk@14419 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-05-03 22:22:34 +00:00
parent b2093dbdfd
commit d2b4e092aa
1 changed files with 4 additions and 3 deletions

View File

@ -2160,8 +2160,9 @@ class WP_Query {
}
$exclude_post_types = '';
foreach ( get_post_types( array('exclude_from_search' => true) ) as $_wp_post_type )
$exclude_post_types .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $_wp_post_type);
$in_search_post_types = get_post_types( array('exclude_from_search' => false) );
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 ) {
$where .= $exclude_post_types;
@ -2847,4 +2848,4 @@ function setup_postdata($post) {
return true;
}
?>
?>