The OpenSearch API provides a flexible common standard for XML-powered searches. WordPress OpenSearch 1.0 worked on WordPress 1.5, but a few changes in the way WordPress deals with DB configuration and HTTP GET parameters caused it to fail in WordPress 2.0. Thanks to tips from James E. Robinson, III, version 1.1 of this plugin now wraps WordPress 2.0’s search functionality. This code should be generic enough to allow anyone to quickly add OpenSearch RSS feed functionality to a WordPress 2.0 site.
The source of version 1.1 is freely available for download here.
Here are six quick steps to getting your WordPress blog running an OpenSearch RSS feed:
Step 1
Download the WordPress OpenSearch code.
Step 2
Unpack the tgz contents into some directory under your wordpress installation. I chose /wp-content/code-plugins/wp-opensearch/. The “code-plugins” part isn’t strictly necessary; that’s just where I happened to put the files, as I didn’t feel right putting them in the plugins/ directory without first figuring out how to integrate the on/off switch with the WordPress admin interface. The php files do have relative require statements which access WordPress’s wp-blog-header.php, so being 3 directories down is important (unless you want to go to the small effort of changing the “../../..” values to reflect your directory structure).
Step 3
Replace logo.gif with your own 64 x 64 pixel image.
Step 4
Open up description.php and change whatever you like. Many values have been prefilled for your convenience. The ones you should be sure to replace are the tags, sample search, and my name and email address, unless you feel like making me more popular than I should be.
Step 5
Edit your .htaccess file so that the paths hardcoded in the PHP files will match up with the actual file locations on your site. Here’s a snippet from my .htaccess file, as an example. Be sure to add this before the line containing “# BEGIN WordPress”, or the broadly-scoped default WordPress rewrites may override yours.
# BEGIN OpenSearch <IfModule mod_rewrite.c> RewriteRule ^os-query?(.*)$ /wb/wp-content/code-plugins/wp-opensearch/wp-opensearch.php?$1 [QSA,L] RewriteRule ^os-description$ /wb/wp-content/code-plugins/wp-opensearch/description.php [QSA,L] RewriteRule ^os-logo.gif$ /wb/wp-content/code-plugins/wp-opensearch/logo.gif [QSA,L] </IfModule> #END OpenSearch
Step 6
At this point, you should be ready to use your new OpenSearch RSS feed. Head over to a9.com and add it to your columns. They have preview functionality which lets you debug any problems you hadn’t noticed before.
The API is:
/os-query?s={searchTerms}&itemstart={startIndex}&itempage={startPage}&itemlimit={count}


January 29th, 2006 at 12:54 pm
Chris, this is great. I’ll update the list of third party tools on the OpenSearch site. BTW, we’re going to take the “DRAFT” off of the 1.1 specs soon with no substantive changes.
February 5th, 2006 at 12:26 pm
[…] Williamsburger - WordPress OpenSearch, v1.1 […]
March 2nd, 2006 at 6:01 pm
[…] Addendum: This is also OpenSearch 1.1-compliant, thanks to: http://www.williamsburger.com/wb/archives/opensearch-v-1-1 […]
March 20th, 2006 at 9:39 pm
I cannot get this version to opperate.
Fails here: $posts = query_posts(”s=$s”);.
June 21st, 2006 at 3:18 pm
Cheers Chris, this works like a treat. Very simple to set up once I had worked out what the Opensearch Description URL was.
August 4th, 2006 at 7:19 pm
A step to add autodiscovery to your wp-header.php might be helpful:
<link type=â€?application/opensearchdescription+xmlâ€? rel=â€?searchâ€? href=â€?http://www.domain.com/os-descriptionâ€? title=”<?bloginfo(’name’); ?>”>
March 12th, 2007 at 10:42 pm
Please forgive a n00b for asking, but there doesn’t seem to be a .htaccess file for my WP Blog, so I’ve tried hard-coding all the path info directly in the description.php file.
But, that doesn’t seem to be my biggest problem. I’m getting errors with the template when I try setting this up to work with A9.com.
Is anyone willing to help me debug this before I hack it completely to death? Thanks in advance for any offers of assistance!