Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $sql = "SELECT ID, ";
- $sql .= "(MATCH(post_title) AGAINST ('%s' ".$boolean_mode." ) * %d ) + ";
- $sql .= "(MATCH(post_content) AGAINST ('%s' ".$boolean_mode.") * %d ) ";
- $sql .= "AS score FROM ".$wpdb->posts." WHERE MATCH (post_title,post_content) AGAINST ('%s' ".$boolean_mode.") AND post_status = 'publish' ";
- // Exclude custom post types from search results
- // Custom post type excluded here is "announcements"
- $sql .= "AND post_type != 'announcements' ";
- $sql .= "AND ( ";
- $multiple = false;
- foreach ($post_types as $post_type) {
- if ( $multiple ) $sql .= ' OR ';
- $sql .= " post_type = '%s' ";
- $multiple = true;
- $args[] = $post_type; // Add the post types to the $args array
- }
- $sql .=" ) ";
- // Exclude post IDs from search results
- // The post IDs are comma delimited
- $sql .= "AND ID NOT IN (100,203,400) ";
- if ($bydate) {
- $sql .= "ORDER BY post_date DESC ";
- } else {
- $sql .= "ORDER BY score DESC ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement