Improving Search in WordPress

I’m sure what I’m about to write won’t be shocking to you – the search in WordPress has sucked since forever. I admit, Google has spoiled us a bit in terms of search. We expect every search box to be working similarly – as in: you input a search term and the most relevant results appear.

Of course, this isn’t how it works in WordPress. WordPress searches the content and then returns a list of all (somewhat) relevant posts and pages and displays the newest entries first. This is far from perfect. What are the chances that your latest post is always the most relevant for EVERY search?

It’s about time this changes!

As you’d probably imagine there are two ways of getting this done:

• Change the core of WordPress.
• Use some plugins.

The former, I don’t advise you to do. The main reason for this is that you are doomed to fail. Not because the search in WordPress can’t be improved that way. Most certainly – it can, but there’s just no point in you sitting and trying to alter the way WordPress operates. WordPress updates are released quite often these days, and the main problem when you alter the WordPress core files is keeping your changes still working after an update.

First of all, you have to preserve your changes, which means you have to manually include your custom lines of code after each update. And more than that, there’s no guarantee your changes will still work in the next version.

My personal opinion (and of course you can agree with me or not) is that if something can’t be done easily from within the functions.php file I don’t bother to modify any other files. Instead, I spend this time on searching for a plugin.

So here we are – not surprisingly, the easiest way of improving the search is to use a plugin. The story repeats itself here because there are two ways you can go with plugins. Some plugins use their own search engine for delivering search results, and others simply use Google.

Using Google

Now, let’s set things straight. If you want the best possible results – the most relevant ones, there’s no better choice than using Google. Google is in the business of search, and quite frankly there’s no one better at it than them. On top of that, they make it possible to use the full power of their search engine as an internal search engine for any website.

(To get a quick preview of what Google thinks about a given search phrase in relation to your site just go to Google and search for: KEY_PHRASE

That being said, there are both some advantages and disadvantages here … as always. The biggest advantage is the aforementioned quality of results. You get the most relevant stuff … every time. Another one is that people are used to using Google and various search operators it provides. Like phrase and broad match, modifiers like intitle: asterisk or the negative modifier, and many more. Once you include Google search on your blog you are automatically providing all of this stuff.

One more advantage is that you can be sure that the search function on your blog will improve over time even further, along with the way Google improves itself. And it will all happen automatically without you even noticing.

Time to talk some disadvantages…

The first and biggest one is that your blog needs to be indexed by Google. And this means that your newest content won’t be searchable right from the get go. In reality, this is just a minor obstacle for popular blogs. Google visits such sites very often – sometimes new posts get crawled within minutes after publication. However, for new and not so popular sites, new content can wait even a week or two before Google bothers to take a look at it.

The second disadvantage is equally predictable – ads. That’s right, in most cases Google displays ads along your search results (not every time, which I will discuss in just a moment), so there is a possibility a visitor might leave your site after doing an internal search. Anyway, despite the disadvantages I think that very soon Google will become the only decent provider of search for most, if not all websites. I’m not saying that it’s good or bad, but from a developer’s perspective this makes life much easier.

Enough talking about search possibilities themselves, let’s take a look at some plugins you can use, beginning with Google powered ones.

First up is Google Custom Search.

You can use it in a couple of different ways. The plugin provides a sidebar widget containing a new search field. So the native search feature in WordPress is not replaced, and you have to make sure not to display two completely different search fields on your blog at the same time.

This widget sends the search term to Google and then displays the results either as a pop-up or inside the widget (in the sidebar) – which isn’t probably the most fortunate way. Also, there’s the third way in which you can display everything manually by using a piece of custom PHP code. For most developers this would probably be a more popular choice.

Note. Before you can use the plugin you need to get yourself a custom search engine at Google. The only downside to this plugin is that it fetches the whole set of results including the ads … something I mentioned earlier.

Another Google powered plugin is Google Search for WordPress. This plugin is much more stealth than the previous one. It replaces the native search in WordPress, so it takes control over every existing search field on your blog, and you don’t have to use any additional widgets.

Furthermore, the results are displayed exactly like your search.php file defines it, and there are no ads. Just the power of Google in its pure form. You still need to remember to abide by Google’s terms of use and place a “powered by Google” message both next to your search form and on your search results page.

The plugin has very little settings. Actually, there’s just one input field on the setting page – a place for your Google Search API Key, which you need to sign up for if you want to use the plugin. Apart from that, there are some plugin hooks you can use to customize the way results are presented.

Using a custom search engine

For me, there’s just one truly cool plugin on the non-Google side of things – Relevanssi. It replaces the native search feature in WordPress with its own search engine, and the amount of possible settings is … serious, to say the least.

For instance, you have the possibility to decide what weights specific elements of content have for search (like titles, tags and comments). You can also choose the default search operator (AND, OR), and exclude some categories, tags, or even specific posts and pages from the search engine. On top of that, the plugin also provides a log of previous searches to give you an insight into what people are searching on your site. This is a highly valuable piece of information when you want to tune your site to better display the most important content.

Hold on, I’m not done yet. There’s also caching, synonyms support, stopwords database, search result highlighting (fully customizable), and much more. I won’t be quoting every feature here, but let me just say that there are well over 30 different settings you can play with in this plugin.

So now what?

These three plugins give you an opportunity to improve search in WordPress to a level where it’s actually usable, and where it can help the blog’s visitors to find the content they’re looking for. That’s the whole point of any search engine if you ask me. Now, there’s no best approach you should choose for your next project. Depending on your specific situation different plugins can turn out to be the best fit. For me, Relevanssi seems to be the most reliable, and (for sure) the one providing the most features.

Feel free to share your own approach at improving search in WordPress. Are you using any other plugins that work well? Or maybe you have a custom solution of any kind?

there are 7 comments added

  1. Macedh 22nd November 2011

    Nice article, thanks for the insights

  2. Jason Paul 24th November 2011

    Helpful but also confirmed my worst suspicions about WordPress search. In a way Google's hegemony in search appears to be stifling innovation (or at least effort) for other search possibilities. Especially in WordPress where it's sorely need. I've tried Relavansii and was somewhat impressed...this was a few months ago and it was a bit too buggy for my own project. I'll probably be moving clients toward Google Search (reluctantly).

    • Karol K 26th November 2011

      Unfortunately, I haven't tried any previous versions of Relavanssi, so I can't make any comparison, but the current one is working just fine for me. Anyway, Google is here to stay, soon we will all have to use their search engine for our projects.

  3. archeffect 7th February 2012

    Thank you very much for such an insightful post. I have been researching how to optimize the internal search within wordpress for a client. Recently, I have seen the Relevanssi plug-in on several threads, I think I will start here. I greatly appreciate listing the pros and cons of the plug-ins, thanks for the info. All the best, AE

  4. Grem Eir 16th September 2013

    Thank you for this tutorial. But I have a problem with Google CSE, my newest post to my blog ( is not indexed right away after it is published. Aside from that, I think they limit only to 200 links indexed for free user. So what if I have more than 200 links? do I need to spend money for an upgrade? is it really a good investment? or i do need to stick to WordPress' native search?

  5. Post ads for free 12th August 2015

    Thank you for providing free classified website, your website is very nice and very well your website is more helpful for all websites.

  6. Namaste UI 30th March 2016

    Nice article for developing and managing WordPress site in niche. This list of information can help the programmers to modify any page without any hesitation. Also for building a plugin this can also help to rebuild the construction of a page. Thanks a lot.

Reset fields

back to top