• Hi,

    I’m trying to order some products by the price but it doesn’t works very well.

    ITEMS:
    product 1 -> price = 12
    product 2 -> price = 28
    product 3 -> price = 34
    product 4 -> price = 234

    THE QUEUE:
    array(
    ‘post_type’ => PRODUCT_POST,
    ‘posts_per_page’ => absint( $number_products ),
    ‘orderby’ => ‘meta_value’,
    ‘meta_key’ => absint( ‘product_price’ ),
    ‘order’ => ‘DESC’
    );

    THE OUTPUT:
    product 3 -> price = 34
    product 2 -> price = 28
    product 4 -> price = 234
    product 1 -> price = 12

    Note: I’m also saving the value of the price with the method absint.

    I can’t figure out what’s wrong.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘My query fails at ordering by meta_value’ is closed to new replies.