/ Published in: PHP
get from wp-include/query.php . Query class , line 1742
Expand |
Embed | Plain Text
// If a search pattern is specified, load the posts that match // added slashes screw with quote grouping when done early, so done later } else { $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); } $searchand = ''; $term = addslashes_gpc($term); $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))"; $searchand = ' AND '; } $term = $wpdb->escape($q['s']); $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')"; $search = " AND ({$search}) "; if ( !is_user_logged_in() ) $search .= " AND ($wpdb->posts.post_password = '') "; } }
Comments
Subscribe to comments
You need to login to post a comment.

Nice snippet. Great basis for a good Search page. Thanks. (I had to revise a few little things there for WP3.3 but all looks good).