I was having the same difficulties. I tried every search plugin out there to no avail.
I added some debugging and dug and dug until I realized the problem was that the ampersand was never being sent to the PHP from the search form.
Finally I figured it out by hacking in some javascript to my theme’s search form.
Note: All this does is change the “&” in a search query to “& amp;” (no spaces) before it is submitted.
WP’s default search engine still does not search successfully when this is done. I am using the Search Unleashed plugin with the “Lucene” search engine (remember to re-index!”). This is the only search engine in the Search Unleashed plugin that works, but other search engines in other plugins may work as well. To test, search for your string with & amp; (no spaces) in it (eg: “AT& amp;T”). If that works and finds AT&T, then this change will allow your users to enter only “AT&T”.
How To:
In the tag for the search form you will need to add the following onsubmit attribute:
onSubmit="s.value = s.value.replace('&','& amp; amp;'); submit();"
** No spaces in the “& amp; amp;”! **
Where the “s
” from “s.value
” is the id of your search input text element.
My form looks like this now:
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>" onSubmit="s.value = s.value.replace('&','& amp; amp;'); submit();" />
<div><input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
<input type="submit" class="button" id="searchsubmit" value="Search" />
</div>
</form>
Note: This isn’t a perfect fix. For example, the Search Unleashed’s landing page search box will not quite work. If you searched for AT&T, it will show ‘you landed here by searching for “AT”, instead of “AT&T”. You can turn that landing page notice off though.
Hopefully this helps you. It was a dealbreaker for me and I sweated the solution for far longer than it should have taken. I’d love to see WP handle this more elegantly.