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: 27,878
Last updated: June 15, 2014
Page on WP Extend

87 thoughts on “Better Search WordPress Plugin

  1. 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

  2. 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?

  3. 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.

  4. 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.

  5. 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).

      • 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.

        • 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?

          • 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!

          • 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.

  6. 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.

  7. 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

    • 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.

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

    John Myrstad

  9. 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.

    • 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.

      • 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.

        • 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

        • 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

        • 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

          • 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.

      • 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.

  10. 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

  11. 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

  12. 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

  13. 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.

  14. 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.

    • 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?

  15. 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.

  16. 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!

    • 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

  17. 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..

    • 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

  18. 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 ?

  19. 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?

  20. 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!

    • 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

  21. 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.

    • 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

Leave a Reply