问题
I've been looking for a way to change the WordPress searching mechanism. My database has several custom tables, which I want to take into account when searching the site. Also, I wan't to implement a levenshtein function for coming up with lines like "Did you mean [another term]?" when somebody makes a spelling error.
Is there a hook, action or function I can implement or change to allow these kind of functions? Any help is greatly appreciated.
Kind regards,
Reinder
回答1:
You could just replace the WordPress search with your own search, by replacing your own search box with a custom search box which then calls a function which uses one of these searches. This will allow you to replace the default wordpress search without modifying the core files.
Three possible options would be:
- MySQL Match Against
- Sphinx
- Lucene
I had to do a similar thing for my own WordPress site. I originally went with MySQL match against, but I have since switched to Sphinx. I ran into serious speed issues using MySQL match against, although those problems vanished when I switched to Sphinx.
来源:https://stackoverflow.com/questions/5538098/rewrite-change-wordpress-search-mechanism