WP Custom Fields Search v 0.2 beta

Front End ScreenshotThis is my search plugin for wordpress, designed to filter posts in a more structured way than the default wordpress search.  Specifically it allows multiple form inputs to be configured to search different aspects of a post, i.e. one term could search the post content, one the post title and one could search a custom field associated with the post.

The blog admin is able to build a customised search form.  It allows you to search by the standard post information and by custom fields and to choose what HTML form elements should be presented for each search field.

I originally developed this plugin for a client project.  Basically the problem they had was that they were storing real estate data as wordpress posts with associated custom fields and they wanted to search for entries based on price, location and features which was not possible with the default wordpress search.

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

I have tested with the following software versions, other versions may or may not work.

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

  1. Install the plugin.  Download it here unzip it in your wp-content/plugins folder, then activate it in the plugins > installed page of your wordpress admin site.
  2. Add the widget to the sidebar on which you want it to appear. Go to the appearance > widgets section of the admin page, in the list on the left find the widget “Custom Fields Search” and click the add button next to it.  It should appear in the list on the right.  Click save changes
  3. You should now have a basic search from on the front of your site, to customise this further read on to see how to reconfigure your fields.

Setting up the fields

Admin Screenshot

Admin Screenshot

Each field has a number of settings which control the way the input appears to the user and the way the search is performed.  Most of the settings are hidden when you first go to edit the widget and you will need to click the show/hide config button to get access to many of the parameters.

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.

Some widgets will require extra options in the Widget Options field.  At the moment this is just the drop down and radio button widgets which allow you to specify a list of values for the user to choose from.  If you leave the options blank then they will be automatically populated with a list of all values currently in the database, this can be useful for fields like categories and tags, but is less useful for fields like title which would just generate an entry for every post in the blog.  If you want to specify the values manually 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.

Extending Custom Search

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.

This plugin is at quite an early stage in development though so it is likely that future versions may not be compatible with the same extension interface and it is likely that any extensions will need altering when new versions are released..

Changes since v0.1

  • I’ve reworked the UI and added some more sensible default values, hopefully this should make it less daunting for new users.
  • Fixed a few bugs.
  • Added in textual descriptions of the search parameters (for themes which support this)

Category: Wordpress Plugins | Tags: , , , 23 comments »

23 Responses to “WP Custom Fields Search v 0.2 beta”

  1. Rowan

    Heya – looks like a great plugin, is there a way that it could be called in a theme not using a widgets? like just a line of php that could be put into a custom page template?

    cheers!

  2. Don

    Not at present because all the config is done through the widgets part of the admin section. I was planning to put in a preset option where a form could be configured through a plugin config page (rather than widget config) then re-used in multiple sidebars, so when I do this I could put in an option to pull in presets through the template. I’m going to put up a new release tomorrow, mostly for compatibility with older wordpress versions, but if that functionality would be a priority I can try to bring it forward. If it doesn’t make it into tomorrow’s version it will be available soon.

    Thanks, Don

  3. ibrahim

    Hello,
    it is a great plugin, it is what i have been exactly looking for. But with one major feature; like Rowan, I need to use it not in the widget but by embedding a page.
    Looking forward for the tomorrow release.

    Thanks again
    ibrahim

  4. Don

    The new version, with preset functionality is now up:

    http://www.don-benjamin.co.uk/wordpress/projects/foss/wp-plugins/wp-custom-fields-search-03/

    I probably need to tidy it up a bit, but the basic functionality should be there.

    Let me know what you think.

    Don

  5. How to Get Your Ex Back

    After reading through the article, I just feel that I really need more info. Can you share some more resources please?

  6. Rotten Monkey

    This seems like it would be a potential solution to my problem. I have a site with 100,000 posts. All using several custom fields (between 8-10 each). I am currently using the SEARCH EVERYTHING plugin, which worked great when I only had about 40 posts, however, since the completion of the site, search queries now take anywhere between 20-30 seconds to complete. Far too long.

    Currently, the only search capabilities that i need are the following:

    Post Title
    Custom Field Values
    Categories

    So, now that you understand my scenario, I have two quick questions….

    1) Can your plugin handle this type of search and not take 20-30 seconds to complete the query and deliver the results to the user?

    2) Is there a script that I can simply embed into the search.php files rather than have a widget search box? I am looking for a solution to input directly into the current search bar on my site.

    Thanks in advance for any help you can give.

  7. vimal

    I have tried to integrate custom-field search plugin and also there i have integrate wp-pagin plugin, now issue is that when i got result on more than 5 post than by paging next link will highlight but when i click on that next link or page number it will give me 0 result found. any solution if possible.

  8. Industrial Training Chandigarh

    Thx for taking the time to explain the terminology towards the novices!

  9. estate agents northampton

    Though I haven’t tried this but I guess this will be very great!

  10. bhhpqhpnsspe

    Don’t Consider Loan Supplement Based Specifically On Curiosity Rate, north face sale The most home home mortgage refinance loan may not come along with the lowest apr. You have to give some thought to the various features coupled with services very.
    Common names of this specific specie of salmon integrate fees like tyee, arises, mouth/kings uggs for cheap online quinnat course tule.
    automobile. Over these sort of everyday outfits, a water-resistant overall uggs cheap , boots and bibs usually are likewise had to assure one might stay dry up since originating from a hook-up, numerous fish will probably resist using maximum problems.

    References:
    north face jackets for men and ugg triplet boots
    cheap ugg boots,cheap uggs,ugg boots canada
    cheap uggs,uggs canada,uggs cheap

    8bb5f029614692f0e210461aed5edd78

  11. pilip

    Hello guys After reading through the article, I just feel that I really need more info. So I’m waiting for some moore…
    Thank you

  12. Cerwaydroro

    Nearly 1 by means of [url=http://www.cheapjimmychooshoesuk.com/]Jimmy Choo UK[/url] that most effective the possibilities for working out galoshes and for boots may very well be just about the most severe alternative you are going to as getting runner.Though as compared to this advice black-jack shoe is especially an important high-profile celestial bodies creating organization, everywhere buyers, this version of really enjoy individuals. commonly used foremost because of the inaccurate surgery jimmy choo retain [url=http://www.cheapjimmychooshoesuk.com/]Jimmy Choo Sale[/url] fantasy arise the case, along with heel pain,The year 2011 jimmy choo as well as live on the internet competitively priced bloating concerning the Achilles tendon adhering to tibial symptoms, leg inflammation, stretch bony injury, [url=http://www.cheapjimmychooshoesuk.com/] http://www.cheapjimmychooshoesuk.com/ [/url] mysterious fingernails, on top of that other folks.
    mnbvcxz0030

  13. zero

    ok… =)

  14. Plantillas para wordpress

    I have found sites provide reviews of Wordpress themes but very few of them offer SEO review of Wordpress themes. Any of you know a site which offers tons of Wordpress theme review in the SEO aspect?

  15. Erminia Boerner

    Heel pain is sometimes painful. What i do when i have severe heel pail is just take some pain medications to keep the pain away. “`,,`

    Hope This Helps! http://www.healthmedicinelab.com/sharp-pain-in-breast/

  16. Siva

    Hi,

    Show/Hide Config button is not working. When I click it nothing opens.Any idea why?

  17. Quinn

    great post I’m a huge gambling fan myself from Holland

  18. gannickkad

    Needless to say my blush has lasted a whole year! ,[url=http://airmax2012shoes.en.ec21.com/]air max 2012[/url]

  19. Hipsaifs

    must check gucci outlet FuYukQAt [URL=http://guccioutlet6.devhub.com/]gucci outlet[/URL] with low price CwsMjIIW http://guccioutlet6.devhub.com/

  20. Google

    if you happen to have to one equilibrium additionally well-being once, you can love the opportunity to item regularly! Marketing message structured fair relationship! Missing out on is almost certainly mind and body Installation for your future. Restless

  21. Maria

    Great plugin, i’ve used in with several websites. I’ve only had 1 issue with this plugin, the show/hide Config button sometimes does not work. I’ve tried disabling all other plugins on the site but have been unable to fix the problem.

    Has anyone else had this problem? Is there a workaround?

    And a big thanks to Don for his work on this plugin.

  22. google

    a person withI purchase the couch the minute incidentally moved the size of his. observed your discussions, I usually aim entered a somewhat tranquility, truly ease combined with take main strip, which specifically wrote the program on the Tend not to

  23. hello there

    Post writing is also a fun, if you be familiar with
    then you can write or else it is complicated to write.


Leave a Reply



Back to top