OpenSearch – Search Field For Mozilla And Internet Explorer With WordPress

Nowadays search field in your browser improved quite a bit, even IE supports OpenSearch format. But what is so great about OpenSearch and how easy it is to use with your WordPress installation has two aspects: WordPress comes already with OpenSearch and it's easy configurable with XML.

in IE 7

You just have to put a link in your theme and a xml file on your server to let the browser know that your blog supports the search field. So go ahead and improve your Plugin with little work and no use of a Plugin.

The following code should explain it. Adjust the syntax and link to the favicon and xml-file.

After you uploaded both files (favicon.ico und os.xml) add a link into the header.php of your theme. You can use the code one by one if you put os.xml in your root. After that it's possible to integrate your blog in Firefox and Internet Explorer.

The declaration of each XML tag is well documented on the OpenSearch website.

for the head area in your template - header.php:

<link rel="search" type="application/opensearchdescription+xml" title="<?php bloginfo('name'); ?>" href="<?php bloginfo('url'); ?>/os.xml" />

XML file:

Copy code, adjust and save as os.xml, then upload on your server.

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
	<ShortName>bueltge.de [by:ltge.de]</ShortName>
	<Description>Use bueltge.de to search on blog.</Description>
	<Url type="text/html" method="get" template="http://bueltge.de/?s={searchTerms}"></Url>
	<Contact>info@bueltge.de</Contact>
	<LongName>bueltge.de [by:ltge.de] Weblog Search</LongName>
	<Image height="16" width="16" type="image/x-icon">http://bueltge.de/favicon.ico</Image>
	<Tags>Weblog WordPress Webdevelopment</Tags>
	<Url type="application/atom+xml" template="http://bueltge.de/?q={searchTerms}&pw={startPage?}&format=atom"/>
	<Url type="application/rss+xml" template="http://bueltge.de/?q={searchTerms}&pw={startPage?}&format=rss"/>
	<Url type="text/html" template="http://bueltge.de/?q={searchTerms}&pw={startPage?}"/>
	<Query role="example" searchTerms="blog"/>
	<Developer>Frank Bueltge</Developer>
	<Attribution>
	    Search data Copyright 2007, bueltge.de [by:ltge.de], All Rights Reserved
	</Attribution>
	<SyndicationRight>open</SyndicationRight>
	<AdultContent>false</AdultContent>
	<Language>de-DE</Language>
	<OutputEncoding>UTF-8</OutputEncoding>
	<InputEncoding>UTF-8</InputEncoding>
</OpenSearchDescription>

Comments are closed.

2 comments

  1. hypno

    Ahh, i am still getting errors like: Could not parse XML file http:/mysite/wp-content/uploads/opensearch/search.xml: org.xml.sax.SAXParseException: The reference to entity "pw" must end with the ';' delimiter. Where should that ';' be placed? Sitting here like a duck for 3 hours...

One pingback

  1. 10 Checks to the Perfect WordPress theme - WP Engineer