WordPress.org

Ready to get started?Download WordPress

Forums

WP Query Search Filter
[resolved] custom field with a currency mark (9 posts)

  1. selinaxxx
    Member
    Posted 1 year ago #

    i have a custom field "aprice" and i want to ask whether i'm doing this right: i put aprice in the meta key and Sorting Meta Key fields. then i make it show between the values. but my custom field has currency mark in front of it, and i get no results when i click search. i still get no results when i sort it not numeric but in words.

    am i doing it wrong in terms of meta key, or is it just the currency mark?

    any solution to this? thanks..

    http://wordpress.org/extend/plugins/wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 1 year ago #

    If I am not mistaken you have a custom meta with meta key 'aprice' and the meta field value is like "$100, $200, $300". If this is your case, i am afraid you wrongly use the plugin.

    The 'between' compare operator only work with pure numeric. Basically It is the sql query that use to compare numbers only. Since you got currency mark in your custom field it will be not treated as numbers. Therefore you got no result from the search.

  3. selinaxxx
    Member
    Posted 1 year ago #

    what do i need to do in order to get results in search? let's say i wanna get results between $1 and $100? isn't this possible? if not, would you recommend any other pluging that does it? yours was one of the greatest plugins around here that i've seen and i couldn't see any better than this in terms of query search filter.. any help or ideas?

    thanks..

  4. TC.K
    Member
    Plugin Author

    Posted 1 year ago #

    Well,

    In order to use compare (or other sql operator), why don't you store your aprice in numbers only? You can add the currency mark when display the 'aprice'.

    I can't find any other plugin that does the same things. That's why I developed this plugin.

  5. selinaxxx
    Member
    Posted 1 year ago #

    i get my 'aprice' directly from an active xml feed. so, it's not in my hands to remove the currency mark. though, is there any way to start a new meta field and remove the currency mark, i don't know actually. i'm not really a programmer or so. but if i'm told the logic or shown the way, i could do it i guess. because, your plugin is really what i've been looking for.

  6. TC.K
    Member
    Plugin Author

    Posted 1 year ago #

    I don't how your xml feed work or structure is. But basically you can parse the xml data and get rid of the currency mark, then store that numbers in your aprice meta field.

    You can refer to this example

  7. selinaxxx
    Member
    Posted 1 year ago #

    thank you for all the responses. i guess i gotta find a way to remove that mark in order to use the plugin properly.

    thanks again mate..

  8. selinaxxx
    Member
    Posted 1 year ago #

    extra question: will you in the future consider adding currency sorting option to this plugin?

    example

  9. TC.K
    Member
    Plugin Author

    Posted 1 year ago #

    The plugin is basically make use of wp_query class to function.There is limitation in sorting query. However, we can manipulating the query to sort in the way we like, of course it is harder to accomplish.

    The easiest solution that I can think of so far is storing the currency mark in references value in custom field. For example :

    1 => $,
    2 => £
    3 => euro

    The '1','2' and '3' are the values we store in custom field, and the '$', '£' and 'euro' are the values we displayed. Thus we can use the stored numbers as the sorting references.

    will you in the future consider adding currency sorting option to this plugin?

    Well, probably not. Like i said, it is not in wp_query class. However, maybe I will add a filter for search result so that user can manipulating the result by their preferences.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.