Results 1 to 4 of 4

Thread: Price Sorting Error:String not Value

  1. #1
    Affiliate Member AppThemes Affiliate safaj's Avatar
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Price Sorting Error:String not Value

    http://mydomain.com/?sort=meta_value&ke ... &order=asc

    Hi guys,
    the function at the top here is giving me issues

    I have four prices for example and when I run the asc function it ranks them like this:

    1. $280
    2. $3300
    3. $440
    4. $500

    DCowgill is the function sorting my string and not by value - how can i change this? is anyone else havin issues?
    (SEE: 2, 3, 4, 5)

  2. #2
    Amateur
    Not a Verified Customer
    thedave's Avatar
    Join Date
    Jun 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Price Sorting Error:String not Value

    Yes, I am experiencing the same issue. The first number is being sorted. For instance...if I was to sort 5 listings from High price to Low price...it would come out like this:

    $900
    $800
    $3100
    $2100
    $1100

    It is sorting: 9, 8, 3, 2, 1

    Any help with a fix would be greatly appreciated.

  3. #3
    Amateur popsoul's Avatar
    Join Date
    Oct 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Price Sorting Error:String not Value

    Found this solution to the whole Price sorting issue.

    http://wordpress.org/support/topic/277454

    Basically you use this in your sort links
    <a href="?sort=meta_value_number&key=price&order=asc" >
    <a href="?sort=meta_value_number&key=price&order=desc ">

    But then you have to make a few edits to WP. In the main wordpress directory (not classipress) go inside the wp-includes folder and open the query.php file. Then do the following:

    go to line ~2035, after $allowed_keys[] = 'meta_value'; add
    $allowed_keys[] = 'meta_value_number';

    go to line ~2057, after break; add
    case 'meta_value_number':
    $orderby = "$wpdb->postmeta.meta_value+0";
    break;

    I did it and it works for me. If those lines aren't exact for you you may not be up to date with your wordpress. Try upgrading or do a search for the value they said to put your new code in after.

    good luck

  4. #4
    greenfeld's Avatar
    Join Date
    Aug 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <a href="?sort=meta_value_number&key=price&order=asc" >
    <a href="?sort=meta_value_number&key=price&order=desc ">

    this i understand i have to copy where to paste ? header . php . footer where ????

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)