Support

Account

Home Forums General Issues Help with Filters change from Text to Number before the WP_query

Unread

Help with Filters change from Text to Number before the WP_query

  • I have a field that is set as a text field and has years of historic data associated with it. The problem is that the data represents prices. I added in my WP_query sort by price low – high. This works for the most part however I am seeing prices that follow – 1,199.00, 1,299.99, 169.99. This leads me to believe that my sort is working correctly on an alpha sort level but not on a numeric level. Are there any Filters I can use to modify the field before the WP query runs to change it to a numeric field? Or are there ways to modify the field without loosing the data? I have tried to adjust the custom field however I seem to loose the data that is there when I change it from a text field to a number field. Anyone have any experience with this would be greatly appreciated.

    My Query

    $args[ 'meta_key'] = 'price';
    $args['orderby'] = 'meta_value meta_value_num';
    $args['order'] = 'ASC';
Viewing 1 post (of 1 total)

The topic ‘Help with Filters change from Text to Number before the WP_query’ is closed to new replies.