Order search results by relevance, rather than by date.

The ordering logic is as follows:
 * Full sentence matches in post titles.
 * All search terms in post titles.
 * Any search terms in post titles.
 * Full sentence matches in post content.

Each section and any remaining posts are then sorted by date.

Introduces some filters:
 * wp_search_stopwords, to filter stop words ignored in WHERE.
 * posts_search_orderby, to filter the ORDER BY when ordering search results.

props azaozz, wonderboymusic.
fixes #7394.


git-svn-id: https://develop.svn.wordpress.org/trunk@25632 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-09-27 17:33:36 +00:00
parent 4b8896d171
commit cff3bb14e6
3 changed files with 223 additions and 42 deletions

View File

@@ -3316,6 +3316,18 @@ function user_pass_ok($user_login, $user_pass) {
*/
function _save_post_hook() {}
/**
* Formerly used internally to tidy up the search terms.
*
* @access private
* @since 2.9.0
* @deprecated 3.7.0
*/
function _search_terms_tidy( $t ) {
_deprecated_function( __FUNCTION__, '3.5', '' );
return trim( $t, "\"'\n\r " );
}
/**
* Check if the installed version of GD supports particular image type
*