WordPress

Better Search WordPress Plugin

Overview:

The default WordPress search is limited because it doesn’t give you results based on the title or content of the post, but by date.

Better Search replaces the default WordPress search engine with a more powerful search engine. Visitors will find more relevant search results of search terms. You can fine tune results by giving the title or the content more weighting.

Better Search supports templates for perfect integration into your blog template. Template for Twenty Eleven theme included in the package.

Additionally, the plugin will track the searches and allow you to present a “search heatmap” of the most popular searches. Support for WordPress widgets will allow you to easily add this heatmap to your theme’s sidebar or footer.

Features:

  • Automatic: Once activated, Better Search will automatically replace your default WordPress search with more relevant search results
  • Relevance: Search results are automatically sorted by relevance. You can also turn off relevancy based searching, in which case, results are sorted by date
  • Control the results: Fine tune the results by changing the weighting of post title and post content. Turn on BOOLEAN search to override the default NATURAL LANGUAGE search of mySQL
  • Popular searches: Find out what visitors are searching for on your blog. Display a list of popular search terms (daily and overall) on your blog in the form of a heatmap. Widget support for easy integration in your theme
  • Customisation: Support for a template file for perfect integration into your blog template. Alternatively, just input your own CSS styles in the Custom Styles tab in the Settings Page. Check the FAQ for more information
  • Supports cache plugins: Works with caching plugins like WP-Super-Cache and W3 Total Cache
  • Profanity filter: Customise the list of stop words that will automatically be filtered out of search queries
  • Translation ready: Better Search is translation ready. If you’re interested in translating Better Search into your own language let me know.

Requirements:

Installing

  1. Download Better Search.
  2. Extract the contents of better-search.zip to wp-content/plugins/ folder. You should get a folder called better-search.
  3. Activate the Plugin in WP-Admin.
  4. Goto Settings > Better Search to configure.
  5. Goto Appearance > Widgets to add the Popular Searches sidebar widgets to your theme

Options:

Below are screenshots of the default options available in the Settings screen

  1. better-search screenshot 1

    Options in WP-Admin - General options

  2. better-search screenshot 2

    Options in WP-Admin - Output options

  3. better-search screenshot 3

    Options in WP-Admin - Custom CSS

  4. better-search screenshot 4

    Options in WP-Admin - Reset count

  5. better-search screenshot 5

    Better Search widget

In order to display the most popular searches, you will need to add <?php if(function_exists('the_pop_searches')) the_pop_searches(); ?>.

In order to display the most popular searches weekly/daily, you will need to add <?php if(function_exists('the_pop_searches_daily')) the_pop_searches_daily(); ?>.

Alternatively, use the sidebar widget to display the overall or weekly top searches.

You can customize the output by adding a template file in your themes folder.

ChangeLog:

Latest version (1.3.4)

  • New: Option to add noindex,nofollow meta tag to the header
  • Modified: Tracking script now set to bypass Rocket Loader
  • Fixed: Class of header row on search results page. You can now add your custom styles to bsearch_nav_row1 and bsearch_nav_row2
  • Fixed: Widget search heatmap colours were not loaded properly

Read previous entries in the changelog.

Writing and testing plugins takes a good amount of time. If you like the plugin and find it useful and would like to donate something for my work please do click the Paypal Donate button below. The payment is secure. I haven’t filled in any amount. Feel free to donate what you please. Any amount is welcome. Thank you :)

License

All files and their contents are licensed under the GNU General Public License (GPL).

Questions or Bugs

Known Bugs

If you have any questions or would like to report any bugs, please see how you can get support.

Downloads

Download Better Search
Number of downloads: 28,848
Last updated: June 15, 2014
Page on WP Extend

87 Comments

  1. [...] The solution we have here is manual and customized for this blog. So, in order to extend this all WordPress users, I’ve converted the same into a WordPress plugin titled Better Search. [...]

    Reply

  2. Hi there,

    Looks very promising. Is it possible to have it take on the existing Theme Style? How does one change the ‘style’ of the search results page?

    Regards,

    Ray

    Reply

    1. The plugin uses the .bsearch_results_page class for displaying the results. However, for major changes you need to edit the plugin :(
      I’m working on a release that will allow you to use a template page in your theme for this purpose.

      Reply

      1. Has this change been implemented four years later?

        Reply

        1. Yes. It has been part of the plugin for a while.

          Reply

  3. It would save some headaches if the plug-in used the theme’s main page template instead of creating its own and hoping that just calling the header and footer will work.

    Reply

    1. WIP :)

      I think I’ll get down to this ASAP.

      Reply

  4. I’m not using widgets in my site, my sidebars are hard coded. How would I use this plugin?

    Reply

    1. Check out the Options section at the top. There’s code on manually displaying the heatmaps

      Reply

  5. WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), INTERVAL 1 DAY)' at line 1]
    SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL DAY), INTERVAL 1 DAY)

    This is the error I get when I have both Popular and Weekly Popular Search widgets turned on and in the sidebar. Do, or should I give time for the weekly searches to populate? Is this why I am getting this error?

    Reply

    1. What version of mySQL are you running? Can you take this to the forum as there may be some debugging to do.

      Reply

      1. Me too – my ISP uses MySQL version 5.0.32

        Reply

  6. [...] Better Search will provide contextually search your WordPress blogs and then list the results based on relevance. Thus improving your visitors search experience. The plugin integrates cleaning in your blog, completely replacing the inbuilt search. [...]

    Reply

  7. it would be great if the search did not include drafts in the results. i have a ton of posts i’m working on at any given time and they all show up in the search results.

    Reply

    1. Thanks for reporting this. I have already coded it in. Will release this with the new version.

      Reply

  8. The results of my search are much better now! Thanks for that! :)

    The search results page is missing the <html>, <head> & <body>tags.

    Would love to see theme integration.

    Reply

    1. I’m confused by what you mean by missing the and & tags?

      Reply

      1. I edited my post but the html, head and body HTML tags are missing from the search results page.

        Reply

  9. Looks great Ajay, thanks. Going to give it a spin today.

    One feature I’d suggest is the ability to exclude certain pages or posts via the admin interface. This is really useful when you don’t want certain content to be found by users via site search.

    Reply

  10. Very nice, but I have deactivated it. Hidden posts (set as “private”) are appearing as shortform in the results for everyone.
    This should only appear when logged in as admin (like in original WP-search).

    Reply

    1. Thanks for pointing this out. I’ll put in the option to exclude private posts in the next version.

      Reply

      1. Hi Ajay, the exclusion of private posts/pages (and drafts) should be set by default.
        the options may sound like this: “include drafts in search?” and a separated question: “include private posts in search?”.
        the same options with pages.

        Reply

        1. Drafts are completed excluded in v1.1.

          I actually didn’t consider private posts, I’ll put that in the next version.

          BTW, when you say private posts, you mean those password protected right?

          Reply

          1. In the menu for “publishing” an article or page after writing, there are three options: 1. public / 2. password protected / 3. private.
            The “private” postas/pages only might be seen from “logged in” users (admin, authors). Equaly it should be with the search results. The pass-protected posts/pages should be included in search, but only with the headlines and without shorttext (like in WP-original search). The “private” content have to be hidden from public users to keep privacy.
            This was sayed independantly from the options for inclusions/exclusions, you will give in future versions of “better search”. Many greetings from Austria!

          2. If there are some open questions, it might depend on plugins, I am using for options with “private” content and handling of “pages” in search (and RSS): “Is Subpage Of”, “RSS Includes Pages” or others.

  11. Hey,

    This is quite an interesting and unique plugin.
    Can you include an option to turn off “popular search” and an option to exclude pages (i.e. only search in posts, not pages)?

    Thanks.

    Reply

    1. The option is in place with v1.1

      Reply

  12. [...] to subscribe to the RSS feed for updates on this topic.Powered by WP Greet BoxI’ve committed Better Search v1.1 to the repository. It’s been rare that I’ve put in a major release just a few days [...]

    Reply

  13. [...] of people that have tried to fix it through various plugins, and today there is a new one called Better Search. Better Search will provide contextually search your WordPress blogs and then list the results [...]

    Reply

  14. [...] Se la ricerca “embedded” di WordPress non vi basta pi

    Reply

  15. Nice plugin.

    I`d like to request an enhancement. The relevance score isnt intuitive for users and i`d like to see an option to choose other ways of showing relevance like %, stars or anything else that`s more intuitive to understand.

    Relevance Score: 5.153

    Is that much or little ? Whats max ?

    Relevance Score: 75% is much easier to understand.

    John Myrstad

    Reply

    1. I’m been thinking the same thing as well. I’ll need to study this a bit better. Alternatively, I’ll try a “relative” percentage basis for calculation.

      Reply

  16. It seems like search results show [shortcode] used in posts. Maybe they should be filtered out when not rendered ?

    John Myrstad

    Reply

  17. Really like this plugin and giving it a test-drive on my local installation. Search results are way better then the defaults, however there are some points which would be nice if implemented.

    The layout of the search results (table | posts | footer) are still generated in the code. Would be nice if there could be some kind of callback feature where you can replace the output of a post with your own HTML, now you have to hardcode it in the plugin.

    Reply

    1. This is actually a top priority list. Instead of a call back function, I plan on implementing Template Tags (or support for WordPress inbuilt Template Tags). I believe this is a lot easier to implement and understand for users.

      Reply

      1. I have been modifying the plugin, particularly the foreach loop which displays all the posts, so it mimics as if it was in the_loop.

        This makes it much easier to work with as wordpress then has several functions available for displaying the posts.

        Reply

        1. Hi Jan Jaap and Ajay,
          Jan Jaap, could you share your code with us? I’m very interested in how you did this! Maybe it is also a solution for the question by John Myrstad. I’m also stuck with the [shortcodes] issues.
          It looks to me that the_excerpt() handles those codes quite well by eliminating them, which is better than, well, showing the codes themselves :-)

          TIA,

          regards,

          Tom

          Reply

          1. Tom,

            I modified the better-search.php file, adding several variables so that it is tricking wordpress that it is in ‘the_loop’.

            My better-search.php file

        2. Thanks Jan. I’ll implement these changes after my tests into the next version of WP.

          Also internationalize the same accordingly.

          Reply

        3. Thanx a million Jan Jaap and Ajay! I notice your alterations have some Dutch phrases… geen probleem! / no problem! :-) I’ll go check them out!

          Tom

          Reply

        4. Hi,

          just implemented the plugin, with the alterations of Jan Jaap. It is in fact (I think) the solution to the question of John. At least it does the trick for me!

          One comment though: it is a bit unclear to me how the relevance is calculated. Sometimes when I perform a search, I’d expect some results coming up before others. But fair enough, I think it is way better than the original WP-search. Thanx again, Ajay for your good work, and Jan Jaap for your adjustments!

          Regards,

          Tom

          Reply

          1. The relevance is a calculated by mySQL by matching the term with your content.

            I’ll be putting in Jan’s implementation the moment I find the time to update.

      2. I have been modifying and stripping down this modification even further until I came up with the following version for my own website.

        Stripped version of better search

        Basicly what I did is use the filter functions of wordpress and replace the query for fetching the search posts with the one used in better-search plugin.

        Then if you are in the search.php file of your template you can still access the search score via $post->score.

        So again I want to thank you for releasing this great plugin as it improves search results quite a lot.

        Reply

  18. [...] Better Search, el plugin para mejorar y organizar las b

    Reply

  19. [...] of people that have tried to fix it through various plugins, and today there is a new one called Better Search. Better Search will provide contextually search your WordPress blogs and then list the results [...]

    Reply

  20. Hi,

    Nice plugin.

    My suggestion would be a way of turning off popular search/hot searches so that only the contextual search appears if that makes sense.

    Elliott

    Reply

    1. You can easily do that by creating a template file for your theme. Check the link above.

      Reply

  21. [...] Search Unleashed was not reporting by relevance after all. Since then I’ve seen details on Better Search, an alternative plugin that (supposedly) does provide relevance-based results. I’d try it out [...]

    Reply

  22. Hi, thanks for a great plugin.
    Is there any way to limit the summary length in the search results, or eliminate the summary completely? Other options would be to display tags and categories, but these are somewhat addressed in comments above.
    Cheers

    Reply

  23. First congratulations for this great plugin.

    Just a request. Can you create an option to enable/disable showing the daily/week/popular searches ?

    Because, I wanted to just show the Popular searches and was a war to do it :-) . I am almost sure that I messed up with the code. :-)

    Anyhow, thanks for this plugin.

    Best,
    Daniel

    Reply

    1. The Total Popular Searches and Daily Searches are two different widgets / functions.

      Reply

      1. Hi,

        And how do I enable only Total Popular Searches?

        Thanks

        Reply

  24. Hi, great plugin! Congrats!

    I have a question, how I hide contact form (contact form 7- famous plugin) codes from search results?
    Ex: [contact-form 1 "contact"]

    Thanks.

    Reply

  25. Can I exclude pages and search posts only?

    Reply

  26. Thanks for a great plugin.

    I have one problem though and that is that I have a “members area” which “hides” some pages for unregistered, using User access manager (http://www.gm-alex.de/projects/wordpress/plugins/user-access-manager/).
    The “member” pages comes up in the search results, which is not good.
    Is there something I can do to exclude “member pages” in the search results?

    Reply

  27. [...] Until then, download the latest version of Better Search. [...]

    Reply

  28. Hello Ajay,
    It says i need to add the code

    I don’t know where? Is it at the function.php?

    Reply

  29. Hello,

    I like the idea of using the fulltext option very much. Besides your plugin, only one other tried it before: wordpress.org/extend/plugins/spectacula-advanced-search/. In one respect it did it better, because it works with the default search template AND it automatically filters out any result that a certain user should not see. I think it just manipulates the original wordpress query. Reading the comments here, that is a main problem. And for me this are not only private posts, but also post marked by the User Access Manager plugin. So it would be very cool if your – in some respects more advanced – plugin would use this technique too.

    Some other things I really would like to see (sorry, I’m so greedy ;))
    - Support for Boolean Search (with sorting by relevance; I’ve got a solution I used years ago, see below)
    - Support for stopwords (you could use a gettext-string that lists language specific stopwords in a comma separated list and filter them out of the search query); I know you can use the MySQL options for that, but many people don’t have access to that setting
    - Check what minimum word length for fulltext queries is set > mysql_query(“show variables LIKE ‘ft_min_word_len’”) 0 ORDER BY relevance DESC;

    Here we artificially manipulate the relevancy score to give title more weight by multiplying by the constant 1.3. In the above query, it doesn’t seem to matter whether I have 3 fulltext indexes or just one comprising the title and text columns. From my testing, the results appear to be the same.

    Reply

    1. By above query, do you mean the one by the plugin? I have noticed in my testing that the constant needs to be significantly higher because since titles usually have lesser content, the default weight of titles are much higher than the content.

      I have been debating adding in Boolean Search support. It’s most likely to be in a future version of the plugin.

      One thing that I have struggled with is getting better template integration. The issue is that I haven’t figured out a way to manipulate the template as well as maintain the same style of the theme.
      I am considering creating a “default” option that will just manipulate the WordPress query, but give you better customisation on the output if you choose to use the template file.

      Am not sure about stop words and minimum length. Do you see this being used often on your site?

      Reply

  30. 1. Templating is nice but I’m almost completely sure people would find your plugin much much more useful if it’d just “replace” the default search with the advantage of better results but without the need to change a template. The other fulltext plugin does it somehow (I think with the wordpress function “add_filter”), but it’s no more maintained and officially not supporting the current wordpress version. I don’t know anything about writing wordpress plugins, but maybe this old plugin could give some clues…?

    2. Yes, weighting titles higher than content makes sense. There was something missing from my post, so that part didn’t make much sense. See next point…

    3. Adding Boolean search is pretty simple. Only still using weighting is a little bit tricky. And for some reason I only posted part of it and messed the example for ft_min_word_len in my comment. Should have been like that:
    >>>
    Boolean searching has two deficiencies: 1) results are not sorted by relevance and; 2) no method by which to weigh certain columns. There is a way around both of these problems. For example, if I have a table of articles and want to weigh the title more heavily than the text, I can do the following:

    S ELECT *, ( (1.3 * (MATCH(title) AGAINST (‘+term +term2′ IN BOOLEAN MODE))) + (0.6 * (MATCH(text) AGAINST (‘+term +term2′ IN BOOLEAN MODE))) ) AS relevance FROM [table_name] WHERE ( MATCH(title,text) AGAINST (‘+term +term2′ IN BOOLEAN MODE) ) HAVING relevance > 0 ORDER BY relevance DESC;

    Here we artificially manipulate the relevancy score to give title more weight by multiplying by the constant 1.3. In the above query, it doesn’t seem to matter whether I have 3 fulltext indexes or just one comprising the title and text columns. From my testing, the results appear to be the same.
    <<<

    4. The minimum length defines how short a word may be to be used for fulltext search. MySQL default is 4 characters, but you can change it. It's the option ft_min_word_len in the MySQL config; you can easily get the setting with php using mysql_query(“show variables LIKE ‘ft_min_word_len’”). A fulltext search for "Windows xp" would ignore "xp" because it is less than 4 characters. I guess you can see why it might be useful to allow mysql to search for short words.

    5. Stopwords are words that should be ignored in a query. Every language has words that don't really count for relevance. For the english language a (possible) list is here: http://www.textfixer.com/resources/common-english-words.txt. The easiest thing is to remove those word in php (it's also possible to give MySQL a stoppword list, but that requires direct access to these options). Assuming there was no minimal word length a query like "the search for a meaning" would find every post that has a "the", a "for" and an "a", besides the really meaningful words "search" and "meaning". Umm, hope this explanation isn't too gibberish.

    Reply

  31. Is it possible to change the output from the text on the page to the page description?

    Reply

    1. Ally, the plugin supports the post excerpt, so if you’ve used that to describe the post, then this will work

      Reply

  32. Can I use it along with Dave WordPress live search plugin?

    I mean your plugin and instant dropdown, results with Dave’s plugin should deliver more relevant results!

    Reply

    1. You should be able to use it with Dave’s plugin. Better Search captures every search result, so if you use Dave’s plugin it should work

      Reply

  33. Dean Hargreaves August 23, 2013 at 1:52 am

    Is there a way to make the better search also search specific categories from a drop down menu.
    Also how can I make it so that if I search for test it will still bring up results for tester.

    Thank You and brilliant plugin..

    Reply

    1. Dean,

      There isn’t a feature in there to get a specific category search. It is on my to-do list of things to add to the plugin, but not with a confirmed deadline.

      You need to enable Boolean mode and then you can use * to run the query, e.g. test*
      I’m not sure if this works with normal mode i.e. without Boolean

      Reply

  34. How can we change the colors displayed in the widget ?

    We get black for the biggest search (that’s OK) but a pale green for secondary searches (it’s not readable when your background is gray-blue).

    Our website is worticle.com if you need to watch it.

    How can we change the color displayed for the smallest searches in the widget ?

    Reply

    1. Are you talking about the heatmap? You can set the colours under Output Options > Heatmap.

      Reply

      1. Was looking for this too… nice plugin.

        Reply

  35. I just installed ‘Better Search’. Thanks for the great post.

    Reply

    1. Thank you for using the plugin :)

      Reply

  36. Recently I tried better search. It did give better function than the original one, however, I came across a serious search “crack”. When you have a post titled “hydrochloride”, and you won’t get result if you search “chloride”, which is the right half of the full word, you will get nothing. Is this normal?

    Reply

    1. Better Search doesn’t search for partial words. It uses a matching algorithm to check for full words and return relevant results.

      Reply

  37. Hi, is there a way to have Better Search include the author’s name when it’s searching as well? When I go to search and type in the name of the author I’d like to find the articles they’ve written and other people have mentioned that to me as well. If it’s possible, could you please tell me how to do it so that Better Search will do that? Thanks!

    Reply

    1. You can’t do that. The plugin only searches through title and content. Usually, you should be able to access author posts via /author/NAME

      Reply

  38. I am using “Dave’s WordPress Live Search” on my site and as you replied some user that your plugin can be used with it but I wanted to know that will “Better Search” plugin also return better search result in live search.

    Reply

    1. I do not know how Dave’s plugin works. Better Search will give you the more relevant results whenever the search page is visited for a term

      Reply

Leave a Reply