• I’ve built a search form using WP Custom Fields Search.

    The form searches a number of custom fields, all of which work perfectly.. except for one.

    I’ve set up a field in the search form with the following settings:

    Name = Price
    Data Type = Custom Field
    Data Field (name of the custom field) = price_range
    Field Type = Drop down
    Compare = Range
    Numeric = Yes (this is supposed to remove any characters such as $ from the equation)

    Some examples of options in the drop-down list:

    • $1-$29,
    • $30-$69,
    • $70-$100

    An example of data in my ‘price_range’ field in one of my posts could be either of the following:

    $55

    ,or sometimes there may be more than one value such as:

    $10-$14

    No matter what I do, the search returns no results when using this field. It returns plenty of results when I leave this field blank.

    Has anybody experienced any issues like this?

    Please note, as well as the settings above, I’ve also tried a number of other combinations, such as setting ‘numeric’ to no, and removing/including the $ in the dropdown options.

    https://wordpress.org/plugins/wp-custom-fields-search/

Viewing 1 replies (of 1 total)
  • Plugin Author don benjamin

    (@dondon-benjamincouk)

    Hi,

    Sorry for the delay in replying.

    Are you saying the $ sign is included in the price field on your posts? If the data is not stored as numeric values there is not a lot that the plugin can do, if you switch off the numeric option you can compare posts alphabetically but this would have it’s own problems:

    e.g. numerically 100>20 but alphabetically 100<20

    The numeric option is to distinguish between these two cases and is not intended to strip values from the search string (although this is not a bad idea) and cannot without significant overhead strip values from the stored data.

    The only solution I can suggest is to store an additional field with a numerical price for searching. So where you have “$20” for price you would have 20 for search_price and where you heave “$10-$14” for price you would have 10 for search_price. This is not exact (as $10-$14 would not show up on a search for price>10 but is the best I can think of.

Viewing 1 replies (of 1 total)
  • The topic ‘Search prices using drop-down range’ is closed to new replies.