Wordpress Custom Search Plugin 0.1 beta
This is a search plugin with which you can build a customised search form. It allows you to search custom fields, choose multiple search parameters and choose HTML form elements to represent them.
I originally developed this plugin for a client project. Basically the problem they had was that they were storing structured data (real estate properties) but the default wordpress search didn’t allow them to search it in a structured way (by price and location). The plugin I’ve built allows you to configure multiple search input fields, configure the behaviour of each field (eg what options appear in a dropdown) and configure what database fields each input corresponds to (eg post title, post content, a custom field called price).
The plugin is now at point where I think it could be useful to other people although I’m aware that there are a lot of improvements that could be made. Please let me know if you have any suggestions or complaints and I will do my best to get them resolved.
You can download the plugin here.
System Requirements
Tested with:
- PHP Versions 4.4.9 and 5.2.6
- Wordpress 2.7
Quick Start Guide
I will try to put more complete documentation together at some point but for now this is a quick start guide to building a search form.
- Install the plugin. Download it here unzip it in your wp-content/plugins folder, then activate it in the plugins page of your wordpress admin site.
- Add the widget to the sidebar on which you want it to appear.
- Click edit and set-up the fields for your form. (More Info Below)
Setting up the fields
Each field has a number of settings which control the way the input appears to the user and the way the search is performed.

Label sets the label displayed next to the field, you can set this to whatever you want.
Data Type controls what type of data is being searched (i.e. what database table is being used). The standard options are “Post Field” for data such as post title and post content, from the standard wordpress post data, “Custom Field” for data from the custom fields, and “Category” to search on the categories a post is in.
Data Field makes a more specific selection from the data available. The drop down list should give some sensible options, or if you know the name of the database field you want to query you can type this in manually.
Widget controls what type of HTML input is created for the front end of the site. It should be fairly obvious what these do. The inputs called “Auto Values” will automatically create options based on what is in the database.
Some widgets will require extra options in the Widget Options field. At the moment this is just the drop down and radio button widgets (not the auto values ones) which require you to specify a list of values for the user to choose from. You can specify this as a comma separated list of values, ‘a,b,c’ for three options with values ‘a’, ‘b’ and ‘c’ respectively, or if you want to give ‘friendly’ labels to the user you can separate the value from the label using a colon as follows ‘a:Group A,b:Group B,c:Group C’.
The Compare field controls the way that the user input is compared to the data in the database. I would expect the most commonly used of these to be “equals” which requires an exact match between the user data and the database field (useful for category searches) and the “Words in” or “Phrase In” types which will search to see if the user input is a part of the data, rather than a full match, this is useful for things like searching the text of a post. The difference between ‘words’ and ‘phrase’ is that ‘words’ splits the input into a series of words and searches for these individually whereas ‘Phrase’ searches for all the words in sequence.
The “Less Than” and “More Than” comparisons ensure that the data is less than or more than the user input respectively. This is probably only relevant for numeric input but it can be used for strings as well and will search alphabetically. For numeric input it can help to also tick the “Numeric” checkbox as sometimes the database will be set up to compare numbers alphabetically (so that 10 is less than 2).
The “Range” comparison is a little more complicated and requires the user input to be of the form A-B to return results that are between A and B. This is primarily intended to be used for Drop-downs and radio buttons where the values can be set by the site administrator. If you specify the values for the dropdown like the following: “-10:Less Than 10,10-20:Between 10 and 20,20-:More than 20″, then the user will be presented with the options “Less Than 10″, “Betwen 10 and 20″ and “More than 20″ but the search will be done with the values “-10″,”10-20″ and “20-”. Again the numeric checkbox should be used for numeric data.
I hope that helps, please let me know if you have any trouble (or joy) with the plugin or if any of my instructions don’t make sense.
Further Development
For developers, I’ve tried to build this in a modular way to allow extensions to be added, I will try to document this at some point in the future but if you can’t wait then the best places to get started would be to look at the filter ‘custom_search_get_classes’ in custom-search/custom-search.php and the Great Real Estate bridging code in custom-search/bridges/greatrealestate.php.
Category: Wordpress Plugins | Tags: custom fields, custom search, wordpress, wordpress plugin 46 comments »
April 19th, 2009 at 10:36 am
Hey this looks like it could be EXACTLY what i’m looking for.
Just a quick question; is it possible to exclude categories from the drop down list and display only specific ones?
April 19th, 2009 at 2:17 pm
A few people have asked for this functionality, so I’m considering putting in a better interface for it.
For now though, if you write the categories you want to include as a comma separated list into the “DropDown Options” field then only these categories will be displayed.
April 19th, 2009 at 2:37 pm
Exactly the news i was hoping to hear! i don’t mind old skooling it as long as it works i’m extatic
thanks
April 25th, 2009 at 5:46 pm
hey, great plugin. Anyway to get it to search custom tables (ie tables outside of standard wordpress ones) in your mysql database?
thanks for your work!
April 25th, 2009 at 6:27 pm
Hi Ash,
Out of the box, it will not support non-standard tables as the db structure for each will be different so they will each require some custom coding.
I have though designed the plugin for extensibility to allow people to add in the code for non-standard tables. If you are familiar with php you could try to integrate the new tables yourself. I keep meaning to write documentation for the extensibility API but in brief you would need to:
* Look at the great-real-estate.php file in the bridges directory.
* Copy this file into a new file “my-other-wp-plugin.php” and change the class and function names as appropriate.
* Re-write the various functions of the Joiner class to represent the new table.
* Send a copy to me for inclusion in forthcoming releases.
If you are not familiar with PHP you could post a feature request in the bug-tracker and I may try to implement some of the most requested ones myself in future when I have time.
Thanks for your interest,
Don
April 30th, 2009 at 12:38 pm
Hi Ash,
This is a great plugin and it has huge potential.
I’m testing it but I’m unable to change or add a value in the “Data Type” field. When I select “Data Type = Custom Field”
Any Help will be appreciated.
Thank You
April 30th, 2009 at 12:51 pm
Hi Michael,
If the plugin is behaving correctly then when you select “Data Type” = “Custom Field” it should populate the “Data Field” dropdown with a list of all the different custom fields which have been applied to posts in your blog.
Are there custom fields currently applied to posts?
If there are then there must be some kind of incompatibility between the plugin and your blog setup. Do you see any javascript errors when you are managing the plugin? How did you add the custom fields?
Thanks,
Don
April 30th, 2009 at 1:56 pm
Hi Don,
I must admit I’m using the Custom Fields Plugin, on the site I’m testing your Custom Search. I’ll setup a conventional Custom field then test it.
No theres no Java script errors on my live setup but I did experience some on localhost (Lampp) .
Will give some feedback, after I remove the Custom Field Plugin.
Thank You Kindly.
November 25th, 2009 at 3:11 am
is this plugin compatible with v 2.8? i was able to activate and set up the search form. when testing it on the live site, page redirects to a long URL that looks like
http://website.com/?cs-post_content=example&cs-=ticket&search=Search&search-class=DB_CustomSearch_Widget-db_customsearch_widget&widget_number=2
and the page is blank
I must be missing something obvious.
November 25th, 2009 at 3:12 am
looks to be a great plugin by the way. so far, it seems to be the only (therefore the best) of its kind that I have seen… only if i could make it work on *my* site.. thanks!
June 11th, 2010 at 4:59 pm
how to make the seach box into 1 line only..
horizontal line.
[ text box ] [dropdown category] [search]
July 11th, 2010 at 11:42 pm
thanks alot for this!!
July 31st, 2010 at 4:25 pm
супер статья, спасибо
August 10th, 2010 at 4:54 am
The feeling of independence that a driver receives from his well-tuned automobile is absolutely nothing compared to the independence and thrill a rider gets from his horse. When a rider and his horse operate in concert, it’s like flying. And you also cannot fly if your feet are stuck on the ground. It is why the proper riding boots are so important. Not merely can they aid raise your security during using, they could add flair for your outfit on or off the horse. Regardless of whether you happen to be browsing for English tall ride-on boots, western boots, paddock boots, or simply the best leather using boots for fashion, there is an overwhelming variety from which to choose. The very best fit is essential, as are the proper supplies, construction, and, of course, cost. We’ll take a appear at a number of the greatest ride-on boots to get you started.
Therefore I’ve purchased many equine shoes on Germany, they really are termed “Reiterstiefel” truth be told there:
My own query: How for you to put together individuals boots by means of this different wardrobe?
Reiterstiefel:
Reiterstiefel guenstig
August 28th, 2010 at 5:39 pm
Я надеюсь завтра будет…
Я считаю, что Вы допускаете ошибку. Предлагаю это обсудить. Пишите мне в PM, пообщаемся.
Я считаю, что Вас ввели в заблуждение.
Не пользуюсь
По моему мнению Вы ошибаетесь. Могу отстоять свою позицию. Пишите мне в PM, пообщаемся.
September 11th, 2010 at 4:33 pm
How would I get this to show for instance, in the range section, a week of future posts?
I would like to allow users just select one week of future posts starting with the current day ( I already tried to and that failed).
November 15th, 2010 at 10:08 pm
This is a great opportunity for the Civil Society Organizations to pressurize their respective Government to implement and conscientize the local self governance on UN Women.
December 3rd, 2010 at 5:30 am
We really love this site. Wewish I could come here all the time.
December 16th, 2010 at 1:08 pm
how add 1 o more Drop Down Options? thanks!
May 12th, 2011 at 5:54 am
very nice plugin!
July 11th, 2011 at 10:56 am
Hello there and many thanks for sharing this !!
Does it feature multi custom value check box selection within one particular custom field key?
Cheers.
November 30th, 2011 at 11:16 pm
This is the interesting publish! Many thanks for that! With all the best Luke aka couchgool.
January 5th, 2012 at 7:38 am
dGjiPvsAj ugg boots outlet cLjkAwbYe http://peternorthcott.com
January 7th, 2012 at 11:31 am
Hi,
Thanks for the great plug in, You are really genius.
I have a small doubt regarding this plug in, can i use this plug in for database search(i am using csv to post plug in to create my posts) i want o create a search form to show data from csv files. How can i do this. If this feature is not included…do you have any thought to add this feature?
Thanks
January 7th, 2012 at 11:33 am
Reply to sonia,
Dear sonia,
select the data type as Drop down, below you will see a text box…add values separated by comma. That’s it
March 11th, 2012 at 11:03 pm
can i use this plugin for a result sheet database search? i mean if i make a database with 2 or 3 columns with title ID, roll no , result then how can i search the specific database? I could not express everything. please solve it.
March 31st, 2012 at 4:28 pm
эротика школьниц. обнаженные девушки и женщины в откровенных сценах. множество эротических картинок для абсолютно бесплатного просмотра. великолепные порно фотографии с красивыми девушками. http://omgporno.net/ – эротика бритни
June 2nd, 2012 at 6:53 pm
Потестим…
June 7th, 2012 at 6:54 pm
This is so good. I was looking for this for few days. I tested this, works fine for me. I need one more thing, can i use check-boxes also as drop-down, input-box and radio buttons.
June 29th, 2012 at 3:13 am
Just wish to say your article is as amazing. The clarity on your publish is simply cool and i could assume you are knowledgeable on this subject. Well with your permission allow me to seize your feed to keep up to date with imminent post. Thank you one million and please keep up the rewarding work.
June 29th, 2012 at 3:31 am
Hey There. I found your weblog the use of msn. This is a really smartly written article. I’ll be sure to bookmark it and return to read extra of your useful info. Thank you for the post. I’ll definitely return.
July 4th, 2012 at 1:41 pm
Новая песня звезды украинской эстрады http://www.youtube.com/watch?v=mH1VM72b4gg
July 14th, 2012 at 11:16 am
интернет проект http://vandrouka.by/ предлагает большое количество информации для тех, кто мечтает посетить Беларусь. узнайте, что посмотреть в Беларуси. места Белоруссии и отдых в Белоруссии.
August 13th, 2012 at 4:33 pm
Ӏ blog quite often аnԁ I tгulу thank you foг your content.
The artiсle hаs truly peаkеd mу interеst.
I will bοok mагk уοur ѕite аnd κeep
checking fοr nеw dеtаіls about onсe
рer weеk. I oρtеd іn for yοur Feed аs wеll.
September 26th, 2012 at 4:42 pm
good topic, this is going to help a lot of people get the whole concept. lista de email lista de email lista de email lista de email lista de email
December 3rd, 2012 at 6:17 pm
Unless I’m mistaken, this doesn’t seem to work for Custom Post Types. Is there an easy fix I could make to have it search them?
Thanks!
December 22nd, 2012 at 10:00 pm
I have read several good stuff here. Certainly worth bookmarking for
revisiting. I
wonder how much effort you put to create such a wonderful
informative web site.
March 5th, 2013 at 11:53 am
Thanks for sharing such a good opinion, post is good, thats why i have
read it fully
April 10th, 2013 at 3:38 am
I think this is one of the so much important info for me. And i’m glad reading your article. But wanna observation on some common things, The website taste is ideal, the articles is really great : D. Just right process, cheers
April 10th, 2013 at 3:50 am
Hey there would you mind sharing which blog platform
you’re using? I’m going to start my own blog soon but I’m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely
unique. P.S Apologies for getting
off-topic but I had to ask!
April 10th, 2013 at 4:02 am
An interesting discussion is worth comment.
I think that you need to publish more about this issue, it may not be
a taboo subject but usually people don’t talk about such subjects. To the next! Kind regards!!
April 14th, 2013 at 12:07 am
This paragraph is actually a pleasant one it helps new internet viewers, who
are wishing in favor of blogging.
April 15th, 2013 at 1:18 pm
Кредит для бизнеса в Москве – надежно телефон:8(495)769-53-05 Игорь (Москва)
April 15th, 2013 at 5:00 pm
Кредит для бизнеса в Москве – надежно телефон:8(495)769-53-05 Игорь (Москва)
April 18th, 2013 at 9:04 am
hey there and thank you for your information ? I’ve certainly picked up something new from right here. I did then again experience a few technical points using this web site, as I experienced to reload the site lots of times prior to I could get it to load properly. I had been brooding about if your hosting is OK? Not that I am complaining, however slow loading cases times will sometimes affect your placement in google and can harm your high-quality ranking if ads and marketing with Adwords. Well I am adding this RSS to my email and could look out for much more of your respective fascinating content. Make sure you replace this once more soon..
May 17th, 2013 at 8:40 am
your plugin doesnt work :p