John Blackbourn wrote a cool related searches feature for Relevanssi Premium. It’s included from version 1.7.4.
In order to use the related searches, you must have search logging enabled and a good log of past searches. Then add the following code to your search results template in a suitable place:
if (function_exists('relevanssi_related')) relevanssi_related(get_search_query(), '<h3>Related Searches:</h3><ul><li>', '</li><li>', '</li></ul>', 5); |
The first parameter is the search query and the last parameter is the number of searches to show. The rest are about the display.
The function looks at the search log and returns queries which have at least one matching token with the current search. Searching for “john” will match both “john blackbourn” and “john smith”. Searching for “john blackbourn” will match “john smith”, but won’t match “john”, because the function doesn’t suggest queries that consist of only one token.
Also, only queries that have at least two hits and have been made at least twice are included.
When you link to your search results pages like this, it’s highly recommended to tell Google not to display them. Either put robots meta field in your search results pages header saying “noindex”, or use robots.txt to prevent bots from accessing your search results pages. Instructions can be found at Robotstxt.org.