I plan on building more WordPress plugins in the future, so this is a quick plugin I put together to get comfortable with developing for WordPress. This is my first journey into the WP world and I will start by creating a simple WP suggestion plugin. I am referring to search suggestions, the auto suggestion terms that search engines give you as you type into the search box. This autocomplete functionality tries to predict what you mean by displaying search queries based on search term popularity (among other factors) so this data has some value.
One possible use case would be to implement that autocomplete function on your WordPress search box in order to give your users a better search experience (autocomplete search suggestions). In fact, there is a WP plugin for this called WP Google Suggest but it doesn’t work. I dissected this plugin and figured out that the problem occurs with the call to Google. In brief, Google does not have an official Suggest API so the plugin made an AJAX call to a Google script that returned suggestion terms but it no longer works. It’s not completely broken but it no longer outputs json so we cannot retrieve the terms via jsonp, which allows cross domain calls.
In detail, the plugin use to call:
But now this call can only return XML results via:
So, we could still parse the XML result and use cURL but for now, I want to keep it simple. Still, one thing I really liked about this call is that it accepts a services parameter (youtube, books, products, news, images) and will return suggestions from different services (not just Google Search). Will revisit again in the future but for now, I did some searching and noticed that Yahoo had an actual API for this related suggestions data. They say that the API will be shut down in February 2011 but considering that it is still working over a year later, we are going to give it a shot.
Here is the download link for WP Yahoo Suggest WordPress plugin. Let me know if you experience any problems with this plugin in the comments.