How to improve the accuracy of wordpress search? The keywords searched by the user only match the title and content!

users search keywords only match the title and content, if an article title and content does not have this keyword, then do not need to display the search results, hope God can give some suggestions! Thank you

Jan.18,2022

this is the reason for the fuzzy search condition that comes with WordPress. You can find the where condition of sql search in the source code


wordpress. When searching, by default, the title (post_title), content (post_content), summary (post_excerpt) and search keywords are compared with like. For more information, please refer to the parse_search function:

/wp-includes/class-wp-query.php -> parse_search()

if you want to modify it, you can modify

add_filter('post_search', function($seach) {
  // $search
  ...
});
through the posts_search hook.
Menu