Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » meta_query with numeric field not working properly

  • Resolved chlustanec

    (@chlustanec)


    Hi,
    I have a little problem with filtering post through meta_query

    lets say, I have this piece of code

    $args = array(
    	        'posts_per_page'  => '10',
    	        'numberposts'     => '',
    	        'offset'          => 0,
    	        'orderby'         => 'post_date',
    	        'order'           => 'DESC',
    	        'post_type'       => 'property',
    	        'post_status'     => 'publish',
    
                'meta_query' => array(
                    array(
                        'key' => 'wpcf-slae-rent',
                        'value' => $_POST['deal_type'],
                        'compare' => 'IN'),
                    array(
                        'key' => 'wpcf-property-type',
                        'value' => $wpcf_type_filter_values,
                        'compare' => 'IN'),
                    array(
                        'key' => 'wpcf-price',
                        'value' =>  $_POST['price_from'],
                        'compare' => '>=')
                    ),
    	        'suppress_filters' => false );

    Now. Everything works on web launch. All other filters works properly. But when I started test with price filter (it is numeric customm field), it began to be funny. I have one post published for testing with price 18000000. When I insert number 1, it works. It works with numbers 18, 180, … and 17, 170, 1700, …, but when i insert 19, 181, 1801, … it doesnt works. It looks like the filter is comparing numbers from left side. At least results looks like it.

    18(000000) >= 18
    180(00000) >= 180
    1800(0000) >= 1800
    18(000000) >= 17
    180(00000) >= 170
    1800(0000) >= 1700
    18(000000) !>= 19
    180(00000) !>= 350
    1800(0000) !>= 7800

    And I need wordpress to take on mind whole price field.

    I hope that I explained it sufficiently and tah taanybody could point me to right direction 🙂

    Thanks in advance

    http://wordpress.org/extend/plugins/types/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘meta_query with numeric field not working properly’ is closed to new replies.