WordPress OpenSearch, v1.1
Saturday, January 28th, 2006

WordPress OpenSearch, v1.0

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]


#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:


9 Responses to “WordPress OpenSearch, v1.1”

  1. DeWitt Clinton Says:

    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.

  2. alexking.org: Blog > Around the web Says:

    […] Williamsburger – WordPress OpenSearch, v1.1 […]

  3. ?????????? » Joining the 21st Century, One Hack at a Time Says:

    […] Addendum: This is also OpenSearch 1.1-compliant, thanks to: https://williamsburger.com/wb/archives/opensearch-v-1-1 […]

  4. Daniel Says:

    I cannot get this version to opperate.

    Fails here: $posts = query_posts(“s=$s”);.

  5. David Says:

    Cheers Chris, this works like a treat. Very simple to set up once I had worked out what the Opensearch Description URL was.

  6. Mal Says:

    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’); ?>”>

  7. DSL Says:

    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!

  8. f7someeve Says:

    Is it still valid for wordpress? I tried steps but couldn’t make it work. Also I may have missing information, I couldn’t understand using API part. Thank you

  9. Chris Fairbanks Says:

    Unfortunately, I doubt this is valid. I wrote the code above and these instructions almost eleven years ago now, and haven’t looked at it since. I also don’t think A9’s OpenSearch exists anymore.

Leave a Reply